How do I edit a script to sample with replacement (or without replacement) from a known data set, and then calculate the mean and distribution of each sample? For example, given 2000 data points, I randomly select 20 data points each time to calculate their mean, and repeat this process 100 times. How do I calculate the mean and distribution of these 100 samples?
What do you mean by calculating distribution?
Here is a script to take 100 subsets and calculate the mean:
dt = Open( "$SAMPLE_DATA/Aircraft Incidents.jmp" );
:Latitude << Format("Best");
dt << Select Where( Is Missing( :Latitude ) ) << Delete Rows;<BR /><BR />runs = 100;<BR />//runs= 100000;
results = new table("results", add rows (runs), new column ("mean"));
rows = index (1, nrows(dt));
for each({i},index(1,runs),
myRows = Random Shuffle( rows)[1::20];
data = dt[myRows, "Latitude"];
results[i,"mean"]=Mean(data);
);
my Mean = Col Mean(:mean);
Show(myMean);
... and the mean of the means.
And with this script, you can use the Distribution platform to fit the 100 mean values with "all" available distributions:
dist = results << Distribution(Continuous Distribution(Column( :mean )); );
dist << Fit All
