Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const count = 1000
  2. const scores = [...(new Array(count))]
  3.     .map((_, index) => ({
  4.       x: index + 1,
  5.       y: (Math.random() * 100) * (1 - Math.random())
  6.     }))
  7.  
  8. const sum = scores
  9.     .map(score => score.y)
  10.     .reduce((acc, curr) => acc + curr );
  11. const mean = sum/count;
  12. const stddev = scores
  13.     .map(score => score.y)
  14.     .reduce((acc, curr) => ((mean - curr) ** 2))/mean;
  15.  
  16. const zScores = scores.map(({x, y}) => ({
  17.     x,
  18.     y,
  19.     z: ((y - mean)/mean)
  20. }))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement