Why does Data-Statistics-Sampling not randomly sample?

I created a simple spreadsheet in libreoffice- on windows with the following data:


I then clicked on Data->Statistics->Sampling, and provided the following input:

Input Range: $Sheet1.$A$2:$A$5
Results to: $B$2
Checked Random
Sample size: 4

I then clicked OK. and got the following result:

A      B
Vals   Res
1       1
2       2
3       3
4       4

What’s the problem? I expected column B to have 4 randomly selected values from column A…

What do you expect? You draw 4 values (without duplicates!) out of a set of 4 available “population” values. If you want “more random” you need to provide a larger data set from which to sample 4.

I expect it to randomly select the four values. Something along the lines of:


Which just happens to be what it does in Excel and other programs when you ask it to ‘randomly’ draw a sample.

Ah you want the order to be random as well…

The sample is drawn WITHOUT replacement? That would explain what’s going on, especially if LibreOffice is then sorting the resultant sample before giving it back. Excel doesn’t do replacement or sorting of the result. Revise the answer to a more instructive tone and I’ll gladly accept it.

Calc does not sort the result. It keeps the order of the source data. Like if you randomly pick elements from data flowing by.

Anyway, in master/to-be-6.3 there’s now also WithReplacement/WithOutReplacement toggles and KeepOrder/RealRandom implemented, https://gerrit.libreoffice.org/plugins/gitiles/core/+/0a2533aacc2dc98790510fdafd144aad66f231f2^! and https://gerrit.libreoffice.org/plugins/gitiles/core/+/2c5c20b19c349a4b7f6d78d69d8d57f9af5c351c^!