Need help with plotting bivariate normal distributions

8 visualizzazioni (ultimi 30 giorni)
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

Risposte (2)

the cyclist
the cyclist il 23 Apr 2014
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 Commenti
Michael
Michael il 24 Apr 2014
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 il 25 Apr 2014
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.

Accedi per commentare.


Rahul Gulia
Rahul Gulia il 21 Ago 2020
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.

Categorie

Scopri di più su Two y-axis in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by