Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8965959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:55:27+00:00 2026-06-15T16:55:27+00:00

How to plot bivariate Gaussian density function in Numpy and Matplotlib using a given

  • 0

How to plot bivariate Gaussian density function in Numpy and Matplotlib using a given mean and covariance matrix? It could be a surface or contour plot. I want a generic solution using mean vector and covariance matrix which doesn’t involve individual Sigmas.

mean, cov, n_samples = np.array([0.,0.]), np.array([[1.0,0.5],[0.5,1.0]]), 100

Thanks,

@Aso.agile

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:55:28+00:00Added an answer on June 15, 2026 at 4:55 pm

    Here is my try:

    import umpy as np
    import matplotlib.pyplot as plt 
    mean, cov, n_samples = np.array([0.,0.]), np.array([[1.0,0.5],[0.5,1.0]]), 100
    data=np.random.multivariate_normal(mean,cov,size=n_samples)
    pdf = np.zeros(data.shape[0])
    cons = 1./((2*np.pi)**(data.shape[1]/2.)*np.linalg.det(cov)**(-0.5))
    X, Y = np.meshgrid(data.T[0], data.T[1])
    def pdf(point):
      return cons*np.exp(-np.dot(np.dot((point-mean),np.linalg.inv(cov)),(point-mean).T)/2.)
    zs = np.array([pdf(np.array(ponit)) for ponit in zip(np.ravel(X), np.ravel(Y))])
    Z = zs.reshape(X.shape)
    fig = plt.figure()
    ax3D = fig.add_subplot(111, projection='3d')
    surf = ax3D.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,linewidth=0, antialiased=Fals)
    surf.show()
    

    3D surface plot shows the result but it is a bit bizarre!. Any comment or other solutions are appreciated.

    What I expect (and want) is something similar to follow:enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to plot a graph in matplotlib using numpy and meshgrid. I want
I am trying to plot some data using pylab scatter function. I'm using pylab.scatter(X,
When trying to plot a normal PDF with mean=0 and standard deviation=20 using the
to plot a vector I am using something like: plot(1:length(vector),vector) Could scatter be used?
I plot complex data using QwtPlot, so, I reimplement QwtSeriesData for converting my data
I want to plot multiple rowstacked histograms on the same graph using gnuplot. A
I'm trying to plot values as a function of the date (only hh:mm:ss, without
I am trying to plot a graph using gnuplot. I have six text files.
I am using core plot to make a line graph for my iPhone app.
I have a contour plot, I am wondering is it possible to label the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.