如何計算某些行的幾何平均數?幾何平均值可以在Summary 中輕鬆獲得。
但是如何透過公式列計算平均值,對吧?
我搜尋了幫助文件和社區,仍然沒有找到方法。


我想這樣計算:
dt=Current Data Table();
dt<<NEW column=""></NEW>
謝謝!
回覆:如何計算某些行的幾何平均值?另外,我在這裡重新連結一篇關於 SAS 文件中的幾何平均值的部落格文章,該文章內容非常豐富:
https://blogs.sas.com/content/iml/2019/10/02/geometric-mean-deviation-cv-sas.html
回覆:如何計算某些行的幾何平均值?我認為這裡的一個有用策略是使用 JMP 中的“NRows()”函數來調用行號上的索引,如果您對通常在匯總統計中報告的一般幾何平均數計算感興趣(並且是一個) JMP 在自訂總計統計下報告)。


我能夠總結(重現)該線程中使用的兩種方法,並且我將數據表包含在通用資料集中,以供任何人將來參考。乾杯, @派崔克朱利亞諾
回覆:如何計算某些行的幾何平均值?謝謝@朱利安
我試圖一次完成這一切,但沒有讓它像下面的圖片那樣工作:

回覆:如何計算某些行的幾何平均值?你好@ron_horne ,
對於你的問題:“有沒有辦法將第一個 ln 轉換嵌入到第二個公式中,從而保存 2 列過程。”
起初,我認為我們可以使用 Transform Column() 做一些事情,就像我們為平台啟動編寫腳本一樣,例如:
Transform Column( "Log[height]", Formula( Log( :height ) ) )
但是,將其嵌入到列公式中卻無濟於事。 然而,:高度[指數(排()- 10 ,排() )] 將傳回一個矩陣,並將其包裝在 Ln() 中將評估每個項目,因此以下內容應給出解決方案的單列版本:
New Column("Geometric mean height (single column)", Numeric, "Continuous", Format("Best", 12), Formula(If(Row() < 10, Empty(), Exp(Mean(Ln(:height[Index(Row() - 10, Row())]))))) );

@朱利安
回覆:如何計算某些行的幾何平均值?你好@lwx228 ,
你的問題問得好,一定有幾種方法可以得到答案。我會嘗試堅持使用列公式。
建立兩個新列。
1 只需將高度轉換為其自然對數即可。
2 取得第一列移動平均線的指數。
第二列應該為您提供您正在尋找的移動幾何平均值。
您可以從這段腳本中取得公式:
New Column( "log height",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Ln( :height ) )
);
New Column( "Geometric mean height",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( Row() < 10,
Empty(),
Exp( Mean( :log height[Index( Row() - 10, Row() )] ) )
)
)
);
請告訴我們它是否適合您。
我還想請問論壇的其他成員是否有辦法將第一個 ln 變換嵌入到第二個公式中,從而節省 2 列過程。
回覆:如何計算某些行的幾何平均值?我用的是原來的方法,結果是一致的。

謝謝吉姆!
回覆:如何計算某些行的幾何平均值?我不知道 JMP 中有幾何平均函數。應該添加一項,我建議您將其添加到 JMP WishList 中。然而,這並不意味著人們不能做你想做的事。我想出了兩種不同的解決方案。第一個是 JSL 中幾何平均值的原始編碼。在附加的資料表中,名為 GeoMean 的資料列使用該公式。它使用您的請求來計算當前行 - 10 行到當前行的幾何平均值。
If( Row() == 1,
Product = 1;
Range = 11;
);
If( Row() <= 11,
Product = Product * :height;
If( Row() == Range,
Returned = Product ^ (1 / Range),
Returned = .
);
,
Product = Product / :height[Row() - Range];
Product = Product * :height[Row()];
Returned = Product ^ (1 / Range);
);
Returned;
第二種形式是 Dist Platform 中名為 Geomean 的列,它從 Distribution Platform 的輸出中提取幾何平均值,在資料子集上運行,一次對 11 行進行子集化
If( Row() < 11,
returned = .,
theValues = :height[Index( Row(), Row() - 10 )];
_d = New Table( "sub", invisible, New Column( "height", values( theValues ) ) );
dis = _d << Distribution(
invisible,
Continuous Distribution(
Column( :height ),
Quantiles( 0 ),
Histogram( 0 ),
Vertical( 0 ),
Outlier Box Plot( 0 ),
Customize Summary Statistics(
Mean( 0 ),
Std Dev( 0 ),
Std Err Mean( 0 ),
Upper Mean Confidence Interval( 0 ),
Lower Mean Confidence Interval( 0 ),
N( 0 ),
Geometric Mean( 1 )
)
)
);
Returned = (Report( dis )[Number Col Box( 1 )] << get)[1];
Close( _d, nosave );
);
Returned;
第一個公式應該是最快的,因為它不會從頭開始計算每行的 Geomean。