Frage

I have a set of integers x, 0<=x<=255 I need to transform this data in that way that :

  1. Average of values in set == 0
  2. Variance == 1

I can meet first condition with:

array arr[];
av = average(arr);
foreach(x in arr) { x = x - av;}

But I do not know, how to meet second one.

The best idea I have: Compute current variance and divide or multiply all integers by A to get closer to desired variance. Then A=A/2 and repeat until error is small.

(Resembles basic algorithm of estimating square root of x.)

Is there another (more efficient) way of achieving this?

War es hilfreich?

Lösung

After meeting the first condition, I need to divide every number by standard deviation.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top