vendredi 4 septembre 2020

Adding random vectors in a sum

I'm wondering if I am calculating something correctly. I want to draw M normal random vectors and add them like "first element of first random vector multiply random vector 1 plus first element of random vector 2 multiply random vector 2 plus ...", so

m1[0] * m1 + m2[0] * m2 + m3[0] * m3 + ...

My code:

M = 100
sigma = 1
summy = np.zeros(M)
for p in range(1, M):
    m_vector_p = np.random.normal(0, sigma, M)
    summy += m_vector_p[0] * m_vector_p

Does this achieve this correctly?




Aucun commentaire:

Enregistrer un commentaire