How to achieve zero mean and unit variance

조회 수: 7 (최근 30일)
syd
syd 2014년 4월 13일
댓글: Walter Roberson 2017년 1월 30일
I have a matrix 50x3000. How do I achieve zero mean and unit variance
Also How would i normalize the same after applying zero mean and unit variance?
  댓글 수: 3
syd
syd 2014년 4월 13일
Ok sorry for asking in the wrong way. What I meant was once I get zero mean and assign to variable X, then do I dot standard deviation on this variable X, or on the original matrix?
Image Analyst
Image Analyst 2014년 4월 13일
You do it on the shifted version of X. Subtracting the mean merely shifts X without narrowing its distribution. So then you divide to narrow or widen the distribution (X) without shifting it (because it's already shifted).

댓글을 달려면 로그인하십시오.

답변 (2개)

Nils
Nils 2015년 11월 27일
You can use the zscore function to zero mean / unit variance any array of data.
For a given matrix A,
A = reshape(zscore(A(:)),size(A,1),size(A,2));
will return the matrix A where all elements now follow a zero mean / unit variance distribution.
It is important to linearize A as the input to zscore, then reshape the output, because zscore will operate differently if you feed it an N-D array rather than a vector.
  댓글 수: 4
sahana kp
sahana kp 2017년 1월 30일
@Walter Roberson Now getting the answer like this >> mean(cA3)
ans =
Columns 1 through 5
-2.72183709262942e-16 -2.72183709262942e-16 -2.72183709262942e-16 -2.72183709262942e-16 -2.72183709262942e-16
Column 6
-2.72183709262942e-16
>> var(cA3)
ans =
Columns 1 through 5
1.02777777777778 1.02777777777778 1.02777777777778 1.02777777777778 1.02777777777778
Column 6
1.02777777777778
is this nomalized ?
Walter Roberson
Walter Roberson 2017년 1월 30일
Might be normalized. The 1e-16 means are round off error that are impossible to avoid in floating point

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2014년 4월 13일
  댓글 수: 3
Image Analyst
Image Analyst 2014년 4월 13일
Of course some X will be negative. I'd say about half of them will be . Why are you expecting something else ?
John D'Errico
John D'Errico 2015년 11월 27일
How would you have a mean of zero (and a non-zero variance) if some of the elements were not negative?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by