问题描述
我正在尝试估计有多少值落在标准偏差的一部分内。使用经验法则,我们可以声明:
所有值的 34% 将落在平均值和 1 个标准偏差之间 所有值的 13.4% 将落在 1 和 2 之间。
如图所示:
此规则只能告诉我落在整数标准差范围内的值的百分比,但是我正在尝试计算有多少落在标准差的分数范围内。我们以这个例子为例:
public decimal GetEastimatednumberOfValuesWithindistribution(int sampleSize,decimal average,decimal deviation,decimal newDataPoint)
{
var priceDifferential = newDataPoint/sampleSize;
var newAverage = average + priceDifferential;
var averagedistance = average - newAverage;
var fractionalDeviation = averagedistance / deviation;
//How do I return the average number of points between that fall within the average to the newAverage
}
通常如果我有完整的数据集,我可以遍历它并手动检查,但是在这种情况下,我只有关于数据集的信息,而不是所有数据。
我如何估计将落在一小部分偏差范围内的数据点数量?
解决方法
对于正态分布,落在均值 k⋅σ
范围内的值的百分比为 given by erf(k/sqrt(2))
,其中 erf
是 error {{3} }.例如,erf(1/sqrt(2)) =
function 和 erf(3/sqrt(2)) =
0.682689..
。
C# 没有内置于数学包中的 erf
函数(与 0.997300..
不同)。可以在 python 或 SO 上的 wikipedia 上找到数值近似值。