Standard deviation javascript

后端 未结 7 1270
感情败类
感情败类 2021-01-11 10:24

I am trying to get the standard deviation of a user input string. I have as follows, but it returns the wrong value for SD. The calculation should go as follows: Sum values/

7条回答
  •  天命终不由人
    2021-01-11 11:13

    For anyone looking for a more generic solution, here's a standard deviation function added to the Array#. The function expects to be called on an array of numbers.

    Array.prototype.stanDeviate = function(){
       var i,j,total = 0, mean = 0, diffSqredArr = [];
       for(i=0;i

提交回复
热议问题