你好,
我正在尋找一個簡單的東西:數組的中位數。
我發現表格、總結表等複雜的東西......但我需要更簡單的:
假設我有一個陣列(矩陣)A:
A = 1::10;
如何取得A的媒體?
謝謝。
使用斯坦分位數方法,將公式新增至中位數柱子:
New Table( "Utility Data",
New Column( "Consumption", Character, "Nominal", Set Values( {"Electricity", "Gas"} ) ),
New Column( "Monday", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [11.2, 100.4] ) ),
New Column( "Tuesday", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [10.4, 86.9] ) ),
New Column( "Wednesday", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [13, 94.8] ) ),
New Column( "Thursday", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [7.1, 103] ) ),
New Column( "Friday", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [12.4, 112.3] ) ),
New Column( "Saturday", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [11.9, 95.3] ) ),
New Column( "Sunday", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [9.7, 97.8] ) ),
New Column( "Median", Numeric, "Continuous", Format( "Best", 12 ),
// the 2nd argument to the quantile function is a matrix made from the days of the row...
formula( Quantile( 0.5, monday || tuesday || wednesday || thursday || friday || saturday || sunday ) )
)
)
column formula using Quantile to get Mediancolumn formula using Quantile to get Median使用分位數取得中位數的列公式
謝謝 !
我猜@uday_guntupalli明白我的意思了:)和@斯坦_科普羅夫斯基得到了解決方案。
事實上,我一直在尋找矩陣的中位數,因為我無法立即從表中提取它,但也許你可以引導我找到一種方法:
我有一張桌子(如下圖)。 我想以簡單的方式計算每行的中位數。 當然,我需要從計算中排除第一列。 在 Excel 中它很簡單,但在 JSL-JMP 中,我不知道如何簡單地做到這一點(避免堆疊表格,...)。
表格範例:
消費量 週一 週二 週二 週四 週五 週五 中位數
電力 11.2 10.4 13.0 7.1 12.4 11.9 9.7 ?
氣體 100.4 86.9 94.8 103.0 112.3 95.3 97.8
你好@uday_guntupalli ,
您可以對矩陣執行相同的操作,如下所示 -
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
htmat = :height<<GET as="" matrix=""></GET>
//輸出
{500, 63, 5.5}
乾杯,
史丹
@斯坦_科普羅夫斯基,
當我想到這個的時候,我想@薩米爾問,如何對於不是來自資料表的矩陣計算出相同的值? 我查看了腳本索引,似乎沒有直接的方法來計算矩陣的分位數或中位數(除非我錯過了)
你好@薩米爾,
您可以在不帶或帶 by 變數的情況下使用分位數函數,如下例所示。
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
Row() = 1;
median_ht = Col Quantile( :height, 0.5 );
Row() = 1;
median_htbyage = Col Quantile( :height, 0.5, :age );
Show( median_ht ); //Show median height
Show( median_htbyage ); //Show median height by age<BR /><BR /><BR />
Col Median FunctionCol Median Function列中值函數
乾杯,
史丹