Need help with plotting bivariate normal distributions

조회 수: 11 (최근 30일)
Michael
Michael 2014년 4월 23일
답변: Rahul Gulia 2020년 8월 21일
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.

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by