Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const count = 1000
- const scores = [...(new Array(count))]
- .map((_, index) => ({
- x: index + 1,
- y: (Math.random() * 100) * (1 - Math.random())
- }))
- const sum = scores
- .map(score => score.y)
- .reduce((acc, curr) => acc + curr );
- const mean = sum/count;
- const stddev = scores
- .map(score => score.y)
- .reduce((acc, curr) => ((mean - curr) ** 2))/mean;
- const zScores = scores.map(({x, y}) => ({
- x,
- y,
- z: ((y - mean)/mean)
- }))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement