Reputation: 13
I have an array of objects where each object looks like this:
{
name: "John Doe",
score: ""
}
There are multiple objects of this kind in an array where the array is effectively ranked from best to worst so in an array that looks like this:
[{name: "John Doe", score: ""}, {name: "Jane Doe", score: ""}, ..., {name: "Adam Smith", score: ""}]
John Doe will have the highest score out of everyone and Adam Smith would have the lowest score.
The objective is to take a mean score and anything else necessary like standard deviation as input and score everyone in the array on a bell curve around that mean where scores are increments of 0.5 so they would go 1, 1.5, 2, 2.5, ..., 9.5, 10. This should work on large arrays of up to hundreds of elements.
Upvotes: 1
Views: 262
Reputation: 19251
this is more of a statistics question, but to generate such a set of normally distributed random numbers, you would need to use the inverse normal distribution formula.
where x is a random value between 0 and 1, μ is the desired mean, and σ is the desired standard deviation. there are likely statistics libraries for javascript that have a ready made norminv function.
so you would run the function as many times as you need for the amount of records you wish to fill, using a random number generator (0-1) as the input for x, and your desired mean and standard dev, then sort the resulting values and add them to your records. the results should fit nicely on a bell curve.
as for quantizing to 0.5 increments, you may just need to use some form of rounding for that.
Upvotes: 2