Search code examples
matlabprobabilitynormal-distribution

How to calculate probability in normal distribution by Matlab?


I'm new to Matlab and I would appreciate if someone could help. The problem:

IQ coefficients are Normally distributed with a mean of 100 and a standard deviation of 15. Calculate the probability that a randomly drawn person from this population has an IQ greater than 110 but smaller than 130. You can achieve this using one line of matlab code. What does this look like?

I tried like this:

>> max(normpdf(linspace(110,130,100),100,15))
ans =
    0.0213

But not sure if it is correct..

I would be thankful for any help!


Solution

  • Lets check:

    N=1e7;                          %Number of "experimental" samples
    iq = randn(1,N)*15 + 100;       %Create a set of IQ values
    p = sum(iq>=110 & iq<=130)/N    %Determine how many are in range of interest.
    

    This returns a number around 23%.