0
$\begingroup$
  • 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

$\endgroup$
3
  • 1
    $\begingroup$ I think that you could use just percentage for both. I calculate geometric mean. $\endgroup$
    – fuwiak
    Commented Feb 6, 2019 at 23:14
  • 2
    $\begingroup$ 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? $\endgroup$
    – whuber
    Commented Feb 6, 2019 at 23:24
  • $\begingroup$ I mean I'd like to have a score for any array to rank how close it is to the ideal state. $\endgroup$
    – bentedder
    Commented Feb 7, 2019 at 0:07

1 Answer 1

4
$\begingroup$

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:

Loss functions 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.

Calculating mean is equivalent to using MSE, because both are based on squared difference between points. If your numbers have a lower bound of 0, you might want to consider some asymmetric function: maybe log-transform them, and then apply MSE, so that 0.1 and 10 would incur equal loss?

(Image from https://heartbeat.fritz.ai/5-regression-loss-functions-all-machine-learners-should-know-4fb140e9d4b0)

$\endgroup$
1
  • $\begingroup$ Thanks, finding the nomenclature to solve these types of problems is half the battle. Knowing now to google for loss functions and use your examples should get me there. $\endgroup$
    – bentedder
    Commented Feb 7, 2019 at 3:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.