均值和標準差 jmp 14 的蒙特卡洛重樹模擬我在調試重採樣部分時遇到問題。 幫助將不勝感激。
dt=當前數據表();
n=N行(dt);
nSim=1000;
dtMC=新表(“MC”,新列(“模擬”,數字,“連續”),新列(“平均值”,數字,“連續”),新列(“標準差”,數字,“連續” );
對於(i=1, i<=nSim, i++,
dtResample=dt< dtMC<<添加行(1);
dtMC:Sim[i]=i;
dtMC:Mean[i]=Mean(dtResample:X)
dtMC:Std Dev[i]= Std Dev(dtResample:X);
);
dtMC<<圖形生成器(
尺寸(400, 300),
變量 (X(:Sim), Y(:Mean)),
元素(點(X,Y))
);
高級統計建模回复:均值和標準差 jmp 14 的蒙特卡洛重樹模擬我很難診斷出您腳本中的錯誤。 也許另一位成員可以幫助解決這個問題。 我將以此為契機向您展示另一種方法。 如果您使用數據表命令以交互方式重新採樣,那麼您的方式非常有意義。 您可以改為在腳本中使用矩陣運算。
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;
n = N Row( data );
nSim = 1000;
// matrix of simulation results
sim = J( nSim, 3, . );
// resample statistics
For( i = 1, i <= nSim, i++,
X = data[J( n, 1, Random Integer( 1, n ) )];
sim[i, 1] = i;
sim[i, 2] = Mean( X );
sim[i, 3] = Std Dev( X );
);
// make data tabel from matrix
dtMC = As Table( sim, <<COLUMN names=""></COLUMN>
回复:均值和標準差 jmp 14 的蒙特卡洛重播模擬這絕對有幫助。一個問題。 “隨機”如何整數”函數有效嗎? 是否有不同的重採樣技術? 也許更多地控制重採樣的完成方式?再次感謝 :)
回复:均值和標準差 jmp 14 的蒙特卡洛重樹模擬Random Integer() 函數以等概率(均勻分佈函數)返回值範圍內的整數。

它是 J() 函數調用中的第三個參數。 它在矩陣的製作過程中逐行求值,矩陣又作為原始數據矩陣的下標提供。 這種用法相當於放回抽樣,這就是你想要的重抽樣樣本統計。
回复:均值和標準差 jmp 14 的蒙特卡洛重樹模擬似乎它將在每次模擬中替換一行。 是否可以在多行中生成隨機整數值?
回复:均值和標準差 jmp 14 的蒙特卡洛重樹模擬我不明白你的假設(“似乎它將在每次模擬中替換一行。 ") 或您的問題 ("是否可以在多行中生成隨機整數值? ”)。 該腳本對於重採樣統計信息是正確的。 我正在使用您可能不熟悉的矢量化解決方案。 腳本的修改版本包括使用“分佈”平台重新採樣的均值估計值和原始估計值的分佈。
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 );
n = N Row( data );
nSim = 1000;
// matrix of simulation results
sim = J( nSim, 3, . );
// resample statistics
For( i = 1, i <= nSim, i++,
X = data[J( n, 1, Random Integer( 1, n ) )];
sim[i, 1] = i;
sim[i, 2] = Mean( X );
sim[i, 3] = Std Dev( X );
);
// make data tabel from matrix
dtMC = As Table( sim, <<COLUMN names=""></COLUMN>
你在嘗試別的東西嗎? 請更詳細地解釋您上次的回复。
回复:均值和標準差 jmp 14 的蒙特卡洛重樹模擬為混亂道歉。 在第一個腳本中,如何將每次迭代中的 X 提取到一個表中,以便在 1000 次迭代中模擬所有值? 再次感謝你的幫助
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;
n = N Row( data );
nSim = 1000;
// matrix of simulation results
sim = J( nSim, 3, . );
// resample statistics
For( i = 1, i <= nSim, i++,
X = data[J( n, 1, Random Integer( 1, n ) )];
sim[i, 1] = i;
sim[i, 2] = Mean( X );
sim[i, 3] = Std Dev( X );
);
// make data tabel from matrix
dtMC = As Table( sim, <<COLUMN names=""></COLUMN>
回复:均值和標準差 jmp 14 的蒙特卡洛重播模擬此腳本生成兩個數據表:一個表包含重新採樣的數據,另一個表包含重新採樣的統計信息。
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 );回复:均值和標準差 jmp 14 的蒙特卡洛重樹模擬謝謝。 一個問題。 如果我有一個數據集 [1 2 3 5 8 9 7] 並且我想按照上面的邏輯進行 2 次迭代,它會創建
2 組通過替換每個位置從數據集中隨機選擇數字?例如:
[3 2 1 5 8 7 7]
[9 1 3 5 2 8 6]
如果這真的是隨機的,那是不是意味著每次運行我們都會得到不同的數據集?