從數據獲取特定的百分數行你好
我試圖弄清楚如何從數據中獲取行值的前25%。基本上是將原始數據的前25%值作為子集。
試過這個;
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
top_25th_perc = dt << Summary(
Group( :sex),
Quantile( :height, .25 ),
Freq( "None" ),
Weight( "None" ),
Link to original data table( 1 ),
output table name( "top_25th_perc" )
);</CODE><CODE class=" language-jsl">
生成下表。

我需要的是dt的子集,兩組中只有25%的行。
怎麼做?
接下來的問題是我們如何才能對這25個百分點進行抽樣,並說從該分佈中獲取一些樣本。 再次匯總數據表是我所需要的。
分析工具數據表腳本編寫回复:從數據中獲取特定的百分位數行我的解決方案可能有些不足。您指示您想要“最高”的25%,然後通過基於25%的百分比進行計算來確定最高的75%。下面的代碼從雄性和雌性中選擇數據前25%的行
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << select where( :height >= Col Quantile( :height, .75, :sex ) );
dtTop = dt << subset( selected rows( 1 ), selected columns( 0 ) );
回复:從數據中獲取特定的百分位數行非常有用,謝謝TXnelson!
有沒有一種方法可以在移動最終數據集之前對那25%的數據進行採樣?
回复:從數據中獲取特定的百分位數行這是我從前25%抽取樣本的方式
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
top25pRows = dt << get rows where( :NPN1 >= Col Quantile( :NPN1, .75, :site ) );
dt << clear selected row states;
// create a 5% of the top 25 percentile data
// Select 5% of the top 25 percentile rows
For(i=1,i<=nrows(top25pRows),i++,
If(random uniform(0,1)<=.05,rowstate(top25pRows[i])=selected state(1));
);
// Create the output data table
dtTop = dt << subset( selected rows( 1 ), selected columns( 0 ) );