Search code examples
matlabplotgraphdistributionprobability-density

Plotting lognormal distribution


This is the probability density function:

Probability Density Function

Code:

f=exp(-(((log(x)-log(100)-(.1((.15)^2)/2))^2))/(2*.15^2))/(x(.15)*sqrt(2*pi));

plot(f);

I can't seem to plot this lognormal distribution in Matlab. I am trying to find what percent of this graph is above 100, and don't know how to do that step in code.


Solution

  • Maybe you'd want to give x some values and define f(x) as an ananymous function

    f=@(x) exp(-(((log(x)-log(100)-(.1.*((.15).^2)./2)).^2))./(2*.15^2))./(x*.15*sqrt(2*pi));
    
    x = 50:150
    plot(x, f(x))
    

    EDIT: Area of the density function for x>=100:

    >> quad(f,100,Inf)
    ans =  0.50299
    

    enter image description here