我有以下代码行:
threshold_value = numpy.percentile(a, q)
其中 a
是我的数据, q
设置为95,我们说。
让我们说,如果我将 q
更改为90,我将获得不同的阈值值。
对于 a
中的每个数据点,我想计算Q的值将产生 threshold_value
等于a的值。因此,我感兴趣的是 a
中的一个数据点低于阈值_value,但是我希望百分位数值确切查看它在哪里。当我有一个测试数据集时,我将每个值与阈值值进行比较,以查看是否超过它。因此,我不想给出AQ值,我想被告知数据点的Q值是什么。
因此,我想要函数,也许 a_percentile = function(a)
,其中a_percentile是对百分位数的原始数据值的转换。
I have the following line of code:
threshold_value = numpy.percentile(a, q)
where a
is my data and q
is set at 95 let us say.
And let us say that if I changed q
to be 90, I would get a different threshold value.
Well for each data point in a
, I would like to calculate what value of q would yield threshold_value
equal to a. So what I am interested in is perhaps a data point in a
is below the threshold_value, but I want a percentile value to see exactly where is it at. When I have a test dataset, I compare each value to the threshold value to see if it exceeds it or not. So I don't want to give a q value, I want to be told what the q value is for a data point.
So I want function maybe a_percentile = function(a)
where a_percentile is a transformation of the original data value to the percentile.
发布评论
评论(1)
使用scipy.stats.percentileofscore :
输出:输出:
Use scipy.stats.percentileofscore https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.percentileofscore.html:
Output: