简体   繁体   中英

Choose out of multivariate normal pdf

I have some questions about scipy.stats.multivariate_normal .

  1. What does it return? I understand that when using:

     var = scipy.stats.multivariate_normal(mean, cov) z = var.pdf([x,y])

    I'll get in z the pdf of this index. Is this true?

  2. I assumed that the mean given is the peak of the pdf. Am I right?

  3. I want to create a 4D map of gaussian pdf, and choose out of it randomly, by the pdf, N points (for particle filter predicting). To use np.choose I need to create an array of the pdf values of shape (M,1) , and an array of the 4D points of shape (M, 4) .

Is there any more efficient way to do this?

The normal distribution is quite ubiquitous and implemented in many different places, so I think you would be better off using the random normal sampling from numpy: https://numpy.org/doc/stable/reference/random/generated/numpy.random.normal.html . In this function you can specify the shape of the output.

using DIN's answer, that's what I did:

x_predict = np.random.normal(mean[0], covs[0], N)
y_predict = np.random.normal(mean[1], covs[1], N)
sx_predict = np.random.normal(mean[2], covs[2], N)
sy_predict = np.random.normal(mean[3], covs[3], N)
particles = np.dstack((x_predict, y_predict, sx_predict, sy_predict))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM