BreakingBytes / simkit

Model Simulation Framework
http://breakingbytes.github.io/simkit/
BSD 3-Clause "New" or "Revised" License
27 stars 16 forks source link

Scale cov incalcs #53

Closed mikofski closed 8 years ago

mikofski commented 8 years ago

calculated covariance is in absolute units, so before storing in out_reg, need to scale it back to fractios

((1/R.T*I) * cov) * (1/R.T*I)

where R is the return values, I is an identity matrix and cov is the covariance.

This was expensive for some reason, lots of zeros? so instead use broadcasting:

cov = cov.T * 1/R  # align last axes along observations, and scale in one direction
cov = np.swapaxes(cov, 0, 1) * 1/R  # transpose each observations covariance and scale in other direction
cov = cov.T

Hopefully it works, needs more testing probably. :smile_cat: