# standard deviation with mean for final score [closed]

• I have an array of numbers
• The goal is for every number to be as close to 1 as possible

The way I have interpreted this is that I want a mean as close to 1 as possible for the whole array, and a standard deviation as close to 0 as possible for the whole array.

Question: How do I combine the mean and the standard deviation in a meaningful way to show a score for "how close" my array is to the goal. The array can be any size.

Examples:

[.9, 1.1, .9] is a good solution

[.2, .5, .3] is not a good solution

[0, 0, 0] is the worst solution

[1, 1, 1] is the best solution

• I think that you could use just percentage for both. I calculate geometric mean. Commented Feb 6, 2019 at 23:14
• If you have numbers, you have them. In what sense, then, do you want the "mean to be as close as possible to 1" and the "SD as close as possible to 0"? If you're willing to change the numbers arbitrarily, there's a unique and obvious solution: set them all to 1. I doubt you're asking that, but what are you trying to ask?
– whuber
Commented Feb 6, 2019 at 23:24
• I mean I'd like to have a score for any array to rank how close it is to the ideal state. Commented Feb 7, 2019 at 0:07

What you are looking for is called a loss function - function $$l(target, data)$$ that describes how far the current $$data$$ is from the $$target$$. Searching for this on google or this website will give you many sources, but here's a summary of the basic ideas:
This plot shows several common loss functions for target 0. Their choice depends on your goals. MSE (mean squared error) grows steeply, which in your case means that any numbers far from 1 will be "punished" badly: $$[0.7, 1, 1]$$ will appear worse than $$[0.9, 0.9, 0.9]$$. MAE grows slowly and would mark both of these examples as equally close to target.