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$

closed as unclear what you're asking by Michael Chernick, kjetil b halvorsen, user158565, mkt, mdewey Feb 7 at 10:02

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ I think that you could use just percentage for both. I calculate geometric mean. $\endgroup$ – Paweł Feb 6 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 Feb 6 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 Feb 7 at 0:07
3
$\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$
  • $\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 Feb 7 at 3:48

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