A user would like to know if it is possible to specify a data set say, x:=[1,2,3,4,5,6] and then extract a random sample from that data set, i.e. xsample:=[3,2,4] for a bootstrapping-type calculation.

We suggested they use something like the following:

restart; with(Statistics); my_data := [1, 2, 4, 5.5, 5.5, 6]; X := RandomVariable(EmpiricalDistribution(my_data)); s := Sample(X, 10); Bootstrap(Mean, X, samplesize = 4, replications = 10000)

HFloat(3.9984625)

(1)

NULL

Download array-random-sample.mw


Please Wait...