亲爱的社区,
我们发现 JMP 计算百分位数的方式与其他程序不同,如何在 JMP 中获得相同的值?
其他程序例如 Oracle SQL 和 Excel (PERCENTILE.INC)
请参阅下面脚本中的一些参考和示例。
谢谢,BR
names default to here(1);
// JMP calculates other Quantiles than Python/Excel
// how to get same values in JMP?
// see:
// web("https://community.jmp.com/t5/Discussions/Quantiles-result-from-JMP-are-different-from-Python/m-p/762983");
// perhaps JMP equal to PERCENTILE.EXC in Excel, and not to PERCENTILE.INC
// Percentile Calculation
// web("https://community.jmp.com/t5/Discussions/Quantile-Percentile-Calculation/m-p/327198");
data = [10.56 10.85 11.08 11.57 11.81 12.27 12.76];
Q80_oracle = 12.178;
// as excel as well
Q80_jmp = Quantile( 0.8, data );
// 12.466
// how can I get same values as in other programs?你好,
我刚刚在 Excel 中测试了您的数据集,我在 Excel 中得到的 Q80 值 = 12.466,与 JMP 完全相同。
我无法在 Oracle 中测试,但我注意到在 R 中,我得到的 Q80 值 = 12.178。此外,R 中的 Q90 为 12.466。
必须解释这些程序之间的分位数是如何计算的。
最好的,
TS
还有一件事:
在 R 中,有 9 种不同的方法来计算分位数。
方法 6 返回与 JMP 和 Excel 相同的 Q80

方法 7 返回您在 Oracle 中找到的 Q80:

最好的,
TS
你好@Georg :我很好奇;你介意我问一下它们是否匹配为什么很重要吗?
各位,
感谢您的输入。我们需要的原因是“客户期望”,即收件人期望以某种方式进行计算。
同时,我找到了一种使用 Python 解决方法的方法,请参阅下面的脚本。
感谢大家并致以最诚挚的问候,
New Table( "Percentile_Cont_Example",
Add Rows( 7 ),
Compress File When Saved( 1 ),
New Table Variable( "SQL",
"with val_tab as
(
select 1 AS lot, 11.08 as value FROM dual
union select 1 AS lot, 12.76 as value FROM dual
union select 1 AS lot,10.85 as value FROM dual
union select 1 AS lot, 11.57 as value FROM dual
union SELECT 1 AS lot, 10.56 as value FROM dual
union select 1 AS lot, 12.27 as value FROM dual
union select 1 AS lot,11.81 as value FROM dual
)
SELECT
val_tab.lot
, val_tab.value
, percentile_cont(0.8) WITHIN GROUP (ORDER BY val_tab.value) OVER (PARTITION BY val_tab.lot) quant80_database
from
val_tab"
),
New Column( "LOT",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 1, 1, 1, 1, 1, 1] ),
Set Display Width( 60 )
),
New Column( "VALUE",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [10.56, 10.85, 11.08, 11.57, 11.81, 12.27, 12.76] ),
Set Display Width( 60 )
),
New Column( "QUANT80_DATABASE",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[12.178000000000001, 12.178000000000001, 12.178000000000001,
12.178000000000001, 12.178000000000001, 12.178000000000001,
12.178000000000001]
),
Set Display Width( 334 )
),
New Column( "Quantile80_JMP",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Col Quantile( :VALUE, 0.80000000000000004 ) ),
Set Display Width( 141 )
),
New Column( "Quantile80_Python",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
data = (As Column( :VALUE ) << get values)[
Loc( As Column( :LOT ) << get values, :LOT )];
Python Execute(
{data},
{result},
"import numpy as np
result = np.quantile(data, 0.8)
"
);
result;
),
Set Selected,
Set Display Width( 292 )
)
)如何为 JMP 18 安装 numpy?我单独安装了 python 3.13.2。我为该版本安装了 numpy,但在尝试运行上述代码时仍然出现此错误
ModuleNotFoundError: Please install the Python package NumPy.
at row 7
脚本索引中的 Python 安装包示例应该可以工作
Names Default To Here(1);
// install numpy and pandas packages
Python Install Packages("numpy pandas");
或者你可以使用 JMP 的 python 端并使用 jpip
import jmp
import jmputils
# update to latest version of pip and setuptools then install numpy & pandas
jmputils.jpip('install --upgrade', 'pip setuptools')
jmputils.jpip('install', 'numpy pandas')
https://www.jmp.com/support/help/en/18.0/#page/jmp/install-a-python-package.shtml#
你试过吗
Python Install Packages( "numpy" );
在 Excel 中有两种方法,
PERCENTILE.INC 和 PERCENTILE.EXC。
我的问题是,我无法在 JMP 中获得与 PERCENTILE.INC 客户相同的值,因此需要使用 python 来解决。