[SciPy-User] affine transformation - what's going on ?

josef.pktd at gmail.com josef.pktd at gmail.com
Fri Jun 3 09:20:36 EDT 2011


I'm puzzling for hours already what's going on, and I don't understand
where my thinko or bug is.

I *think* an affine transformation should return the same count in an
inequality.
x is (nobs, 3)
a is (3)
mu and A define an affine transformation

Why do the following two not give the same result? The first is about
0.19, the second 0.169

print (x<a).all(-1).mean()

print (affine(x, mu, A) < affine(a, mu, A)).all(-1).mean()


full script below and in attachment
-------------
import numpy as np

def affine(x, mu, A):
    return np.dot(x-mu, A.T)

cov3 = np.array([[ 1.  ,  0.5 ,  0.75],
                   [ 0.5 ,  1.5 ,  0.6 ],
                   [ 0.75,  0.6 ,  2.  ]])

mu = np.array([-1, 0.0, 2.0])

A = np.array([[ 1.22955725, -0.25615776, -0.38423664],
               [-0.        ,  0.87038828, -0.26111648],
               [-0.        , -0.        ,  0.70710678]])

x = np.random.multivariate_normal(mu, cov3, size=1000000)
print x.shape

a = np.array([ 0. ,  0.5,  1. ])

print (x<a).all(-1).mean()
print (affine(x, mu, A) < affine(a, mu, A)).all(-1).mean()

'''
with 100000
(100000, 3)
0.19185
0.16837

with 1000000

(1000000, 3)
0.191597
0.168814
'''
------------------

context: I'm transforming multivariate normal distributed random
variables, and my cdf's don't match up.

Can anyone help figuring out where my thinking or my calculations are wrong?

Josef
-------------- next part --------------
A non-text attachment was scrubbed...
Name: try_affine.py
Type: text/x-python
Size: 884 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110603/e74526a2/attachment.py>


More information about the SciPy-User mailing list