在列分位數計算中排除行你好,
我試圖獲取 Col Quantile( :height, 0.5, :class) 但看起來計算仍會考慮排除的行。
有沒有辦法拒絕排除的行進入 Col Quantile 計算?
謝謝,
綠
腳本回复:排除 Col 分位數計算中的行您可以在 Col Quantile() 函數中檢查被排除的行。下面是一個例子
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Col Quantile Height by Age",
numeric,
continuous,
formula( Col Quantile(If(excluded(rowstate(Row())),., :height), 0.5, :age ) )
);
每當數據表中的行的排除行狀態發生變化時,公式將計算新值
回覆:在列分位數計算中排除行我嘗試使用以下程式碼建立一個循環來收集許多參數的第 50 個百分位數,但「test_list」中的兩個元素是相同的(它們都是權重的 50%)。但是,如果我手動運行這些線路,它就會起作用。我可以不在 for 迴圈中使用 Col Quantile() 函數嗎?
名稱預設為此處( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
繪圖參數={
高度,
重量};
測試列表={};
for(plotcnt=1,plotcnt<=nitems(plot_param),plotcnt++,
pct_50=列分位數( If(排除(rowstate(Row())),., 列(plot_param[plotcnt])), 0.5);
test_list[plotcnt]=pct_50;
);
回覆:在列分位數計算中排除行
我嘗試使用以下程式碼建立一個循環來收集許多參數的第 50 個百分位數,但「test_list」中的兩個元素是相同的(它們都是權重的 50%)。但是,如果我手動運行這些線路,它就會起作用。我可以不在 for 迴圈中使用 Col Quantile() 函數嗎?
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
plot_param={
height,
weight};
test_list={};
for(plotcnt=1, plotcnt<=nitems(plot_param), plotcnt++,
pct_50=Col Quantile( If(excluded(rowstate(Row())),., column(plot_param[plotcnt])), 0.5);
test_list[plotcnt]=pct_50;
); 回覆:在列分位數計算中排除行Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
plot_param={
height,
weight};
test_list={};
for(plotcnt=1, plotcnt<=nitems(plot_param), plotcnt++,
Eval (Substitute (Expr(pct_50=Col Quantile( If(excluded(rowstate(Row())),., _col_), 0.5)), Expr(_col_), column(plot_param[plotcnt])));
test_list[plotcnt]=pct_50;
);
回覆:在列分位數計算中排除行由於拼字錯誤,我剛剛注意到 Eval (substitute()) 就足夠了,即使你用 1 替換 1:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
plot_param = {height, weight};
test_list = {};
For( plotcnt = 1, plotcnt <= N Items( plot_param ), plotcnt++,
pct_50 = Eval( Substitute( Expr( Col Quantile( If( Excluded( Row State( Row() ) ), ., Column( plot_param[plotcnt] ) ), 0.5 ) ), 1, 1 ) );
test_list[plotcnt] = pct_50;
);
show(test_list);

回覆:在列分位數計算中排除行@LatentDataTiger ,來自 JMP 支援的回饋 (TS-00139301)
是的,這是一個錯誤。開發人員已證實這是 Col Quantile [& Col Median] 的快取問題。其他 Col 函數就沒有這個問題。使用 Substitute 會在循環的每次迭代中產生一個新表達式,以便快取不會被不當使用。感謝您回報此問題,我將提交錯誤報告。
因此,實際上,它不是Substitute ,而是透過Eval(Expr())進行的保護修復了錯誤。
@Arn_Cota [改編版本] 的一個很好的例子說明了效果:
看更多...Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
plot_param = {height, weight};
test_list = {};
For( plotcnt = 1, plotcnt <= N Items( plot_param ), plotcnt++,
// Without Exclude, returns correct values
pct_50_v0 = Col Quantile( Column( plot_param[plotcnt] ), 0.5 );
// With Exclude, returns the Quantile for height
pct_50_v1 = Col Quantile(
If( Excluded( Row State( Row() ) ),
.,
Column( plot_param[plotcnt] )
),
0.5
);
// With Eval and Substitute, returns correct values
pct_50_v2 = Eval(
Substitute(
Expr(
Col Quantile(
If( Excluded( Row State( Row() ) ),
.,
Column( plot_param[plotcnt] )
),
0.5
)
),
1, 1
)
);
// use Eval(Expr() to protect the expression against inappropriate caching
pct_50_v3 = Eval(Expr(Col Quantile(
If( Excluded( Row State( Row() ) ),
.,
Column( plot_param[plotcnt] )
),
0.5
)));
// Show different versions
Show(
plotcnt,
Column( plot_param[plotcnt] ),
pct_50_v0,
pct_50_v1,
pct_50_v2,
pct_50_v3
);
test_list[plotcnt] = pct_50_v3;
); 回覆:在列分位數計算中排除行新增到JMP 中的表達式處理的範例/解決方法:Tipps 和 Trapdoors