Standard deviation javascript

后端 未结 7 1274
感情败类
感情败类 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:10

    This function works and produces the same result as numjs

    const st = (numbers) => {
      const mean = numbers.reduce((acc, item) => acc + item) / numbers.length;
      return Math.sqrt(numbers.reduce((acc, item) => acc + Math.pow((parseFloat(item) -mean), 2)))
    }

提交回复
热议问题