This script produces two data tables: one table with the resampled data and another with the resampled statistics.
Names Default To Here( 1 );
// example
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// dt=Current Data Table();
// original data as a vector
data = dt:weight << Get As Matrix;
sampleMean = Col Mean( dt:weight );
sampleSD = Col Std Dev( dt:weight );
n = N Row( data );
nSim = 1000;
// matrix of simulation data
simData = [];
// resample data
For( i = 1, i <= nSim, i++,
X = data[J( n, 1, Random Integer( 1, n ) )];
simData ||= X;
);
// make table of resampled data
colNames = List();
For( i = 1, i <= nSim, i++, Insert Into( colNames, Eval( "Sample " || Char( i ) ) ) );
dtSimData = As Table( simData, << Column Names( colNames ) );
// matrix of simulation results
simStat = J( nSim, 3, . );
// resample statistics
For( i = 1, i <= nSim, i++,
simStat[i, 1] = i;
simStat[i, 2] = Mean( simData[0,i] );
simStat[i, 3] = Std Dev( simData[0,i] );
);
// make data table from matrix
dtMC = As Table( simStat, << Column Names( {"Simulation", "Mean", "Std Dev"} ) );
// plot resampled statistics
dtMC << Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables( X( :Simulation ), Y( :Mean ), Y( :Std Dev ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 3 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 4 ) ) )
);
obj = dtMC << Distribution( Y( :Mean, :Std Dev ) );
rpt = obj << Report;
rpt[AxisBox(1)] << Add Ref Line( sampleMean, "Solid", "Red", "Sample Mean", 1, 0 );
rpt[AxisBox(2)] << Add Ref Line( sampleSD, "Solid", "Red", "Sample Std Dev", 1, 0 );