Need help with plotting bivariate normal distributions

10 次查看(过去 30 天)
Hey everyone.
I'll be honest with you, I have no idea what I'm doing here but I'm not asking for answers and instead I'm willing to struggle for them. I'm a civil engineering senior with a minor in applied mathematics. I've taken a basic computer science course my freshmen year but it wasn't very informative (consisted mostly of vocab and lectures and not very much practice) and I've forgotten everything since.
For my last math class I've been given a problem where I've been asked to plot a bivariate normal distribution, with a standard deviation of 1, a mean of 0, and four different correlation coefficients of 0.9, -0.9, 0, and 0.5. Each of these is to be plotted on its own graph, and then four scatter plots should be plotted for each of these graphs using a random sample from a random number generator.
What I really need is a hand on getting this started in matlab. I know this might sound like a lot and again I'm not trying to get you to do my project for me, but I don't think rusty is a strong enough adjective to describe my matlab skills.
Many thanks

回答(2 个)

the cyclist
the cyclist 2014-4-23
That's an honest appeal, and refreshing compared to those who post word-for-word homework problems and don't seem to realize how transparent they are being. Here are two tidbits that might help get you kick-started.
First, try to get firmly in mind whether you understand mathematically (not MATLAB-ly) what you think you are plotting. Could you draw it roughly by hand?
Second, take a look at the MATLAB Plot Gallery. This will give you a bird's eye view of several types of MATLAB plots, with the ability to then download the code that created them. You may find something that is close to what you need, that you will be able to adapt.
  4 个评论
Michael
Michael 2014-4-24
How would I adapt this so that "i" would vary as a matrix of inconsistent variances? I want the matrices to be [-0.9 0 ; 0 -0.9], [0 0 ; 0 0], [0.5 0 ; 0 0.5], and [0.9 0 ; 0 0.9], but am unsure of a way to write it in a way that that does not involve generating a graph for each matrix. I tried defining each matrix as its own variable (m1, m2, m3, m4), but then could not figure out how to write it to cycle through each matrix.
the cyclist
the cyclist 2014-4-25
You can store the matrices in a cell array:
c = {[0.9 0; 0 0.9],[0.5 0; 0 0.5]}; % Two matrices stored in a cell array
Then, when you go through the loop, you can reference
c{i}
to access each matrix.

请先登录,再进行评论。


Rahul Gulia
Rahul Gulia 2020-8-21
I was actually looking into similar kind of problem. And i found solutions that could answer your problem quite properly.
Here are all the relevant links that i am referring from too.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by