Created
June 22, 2011 20:57
-
-
Save dfm/1041170 to your computer and use it in GitHub Desktop.
For Aukosh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import array,sin,cos,cov | |
import numpy.random as random | |
def obs_to_xyz(obs): | |
D,th,phi,vr,vth,vphi = tuple(obs) | |
sth,cth = sin(th),cos(th) | |
sphi,cphi = sin(phi),cos(phi) | |
return [D*sth*cphi, | |
D*sth*sphi, | |
D*cth, | |
vr*sth*cphi + vth*cth*cphi - vphi*sphi, | |
vr*sth*sphi + vth*cth*sphi + vphi*cphi, | |
vr*cth - vth*sth] | |
N = 10000 | |
random.seed() | |
obs = 10.0+random.randn(6*N).reshape((N,6)) | |
print cov(obs) | |
xyz = [] | |
for o in obs: | |
xyz.append(obs_to_xyz(o)) | |
xyz = array(xyz) | |
print cov(xyz) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment