preprocessor - Adjust data vector to have certain variance -


i have set of integers x, 0<=x<=255 need transform data in way :

  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 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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

What is the difference between data design and data model(ERD) -

ios - Can NSManagedObject conform to NSCoding -