preprocessor - Adjust data vector to have certain variance -
i have set of integers x, 0<=x<=255 need transform data in way :
- average of values in set == 0
- variance == 1
i can meet first condition with:
array arr[]; av = average(arr); foreach(x in arr) { x = x - av;}
but not know, how meet second one.
the best idea have: compute current variance , divide or multiply integers closer desired variance. a=a/2 , repeat until error small.
(resembles basic algorithm of estimating square root of x.)
is there (more efficient) way of achieving this?
after meeting first condition, need divide every number standard deviation.
Comments
Post a Comment