【问题标题】:JavaScript: Possible to get percentile by given z-score? Calculating quantile?JavaScript:可以通过给定的 z 分数获得百分位数吗?计算分位数?
【发布时间】:2016-01-10 07:26:00
【问题描述】:

是否可以通过 JavaScript 中给定的 z-score 计算百分位数?

例如z 分数 1.881 应该给我 0.97 或 97%。这个例子很简单,但我想计算 z 分数给出的每个百分位数。

【问题讨论】:

    标签: javascript math quantile percentile


    【解决方案1】:

    Seeking a statistical javascript function to return p-value from a z-score

    你在找什么?

    function GetZPercent(z) {
    
      // z == number of standard deviations from the mean
    
      // if z is greater than 6.5 standard deviations from the mean the
      // number of significant digits will be outside of a reasonable range
    
      if (z < -6.5) {
        return 0.0;
      }
    
      if (z > 6.5) {
        return 1.0;
      }
    
      var factK = 1;
      var sum = 0;
      var term = 1;
      var k = 0;
      var loopStop = Math.exp(-23);
    
      while(Math.abs(term) > loopStop) {
        term = .3989422804 * Math.pow(-1,k) * Math.pow(z,k) / (2 * k + 1) / Math.pow(2,k) * Math.pow(z,k+1) / factK;
        sum += term;
        k++;
        factK *= k;
      }
    
      sum += 0.5;
    
      return sum;
    }
    

    【讨论】:

      【解决方案2】:

      请访问此学术网站: http://sphweb.bumc.bu.edu/otlt/MPH-Modules/BS/BS704_Probability/BS704_Probability10.html

      为了计算百分位值,您需要给它 z 分数(您已经得到),然后乘以均值和标准差。均值和标准差都需要来自样本(例如数据集)。您必须通过某种循环数组的函数来计算这些。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-12-29
        • 2013-06-20
        • 2020-10-07
        • 1970-01-01
        • 2021-02-26
        • 2016-07-28
        • 2017-08-29
        • 2012-10-28
        相关资源
        最近更新 更多