문제

I have a datafile which is in array form. I want to normalize all complex numbers in that array. But I dont want to use z/Abs[z] this approach. I want to use different approach like z-score. For example, in z-score you can find the standard deviation and you can normalize all numbers but I am trying to normalize complex numbers. So how can I do that?

도움이 되었습니까?

해결책

Z-Score for Real numbers:

Z = (X - Avg) / SD

The obvious approach that comes to mind, would be calculating the average & standard deviation for the real plane & imaginary plane independently.

Then we would presumably alter the formula, to use something like sqrt( sum-of-squares) approach to combine real & imaginary components or scores.

Zr = (Xr - AvgR) / SDr
Zi = (Xi - AvgI) / SDi

And finally:

Zc = sqrt( Zr^2 + Zi^2)

This would probably be the most straightforward way of producing a single Z-score from a complex number within it's distribution.

This is of course different from 'normalization', which would retain separate components and what was what I initially answered. But I believe that a single score, measuring distance from the mean, is what you're after here.

다른 팁

you can normalize your complex vector as

norm = np.exp(1j*np.angle(z))

although it is slower but has advantage over

z/abs(z)

since if z is zero and you do above calculation you will get nan. even if you remove nan by 0 you will get 0 any way because normalized length can not be zero. If you use this 0 length normalized vector to set the phase of any other vector you will always get 0. It depends on what you are searching

alternatively you can do

z1=z/abs(z)
z1[np.isnan(z)]=1

because normalized length should be 1

regards

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