Bee AntJared's Blog

FE前端

BE后端

DB数据库

OPS运维

Snippet代码片段

Note笔记

I'm also on

GitHubIf you code

MailIf you talk

RSSIf you subscribe

About.meIf you recommend

Simple Statistics snippet


JS函数式编程计算标准差


const sample = [];

const mean = sample.reduce((x, y) => x + y)/sample.length;

const deviation = sample.map((x) => x - mean);

const std_deviation = Math.sqrt(
  deviation
  .map((x) => x*x)
  .reduce((x,y) => x + y) / (sample.length-1)
);