user1574598
user1574598

Reputation: 3881

Plotting the mean and standard deviation of a given vector?

I've searched high and low for this, and can't seem to find anyone asking this question in its most basic form.

I have a vector x, I have already taken the mu mean and the sigma std, how can I plot this so I can see the spread of the data in the form of a bell curve?

The closest I've come across in the MatLab help is normspec, which I imagine is not what I'm looking for.

EDIT:

Thanks for all you replies. Rather than leave multiple comments, I thought I would edit my original post.

I basically have my column vector x which is populated with heart rate data in (BPM), so I guess if you were plotting the X-axis, it would need to range from 0 to 200. So far just to make my results more tangible, I have been creating constants for the mean and standard deviation (as pointed out). I would like to be able to visualise this data similar to this (similar to the gaussmf function within the Fuzzy logic toolbox):

enter image description here

One of your answers may be correct, but I'm not sure while editing this post. Sorry I have not been clear regarding the mathematical side. I am in the process of learning a probability and statistics course, but so far my source files just reference the standard deviation as the 'spread'.

Upvotes: 1

Views: 1198

Answers (2)

rayryeng
rayryeng

Reputation: 104493

Use the hist command. @OliCharlesworth is correct. You can use hist(x,nbins); to specify how many bins you want.

For example, since your BPM goes from [0,200], maybe you can split up your histogram so that they are binned in 20 BPM intervals, so you'll need 10 bins. As such, try doing hist(x, 10);

A histogram is basically a frequency counter. With the above example, what you are doing is gathering data so that they fall within certain bins. If we select 10 bins, this means that you will have 10 frequency bins such that the first reflects those how many BPM are between [0, 19], the second are between [20, 39] and so on. The more bins you have, the smaller the spacing there is in between successive bins.

I don't know how many bins you want for your application, but play around with the nbins parameter and see what you get.

Upvotes: 1

mban
mban

Reputation: 442

The equation for a bell curve is given as:

f(x, mu, sigma) = (1/(sigma*sqrt(2*pi)))*e^(-(x-mu)^2/(2*sigma^2))

I couldn't find a way to put it into a more easily read mathematical equation so here's the link if you're interested: http://en.wikipedia.org/wiki/Normal_distribution

The values you found (mu and sigma) are constants. To fit it to a bell curve you need to simulate the curve. x in the equation should just be a vector or array to plot against (this is dependent on your data) and should just be the length of your original data.

Hope that makes sense.

Upvotes: 1

Related Questions