문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top