MATLAB Answers

how to make a curve of Poisson, Rayleih, t , ....etc distribution of my random data (in histogram)

55 views (last 30 days)
I am looking for the best shape that can fit with my histogram(in pdf). I tried with dfittool, but its does not include all types of distribution. and also I used the goodness fit.


Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 10 Jan 2019
If you have the Statistics and Machine Learning Toolboox, then you could use the fitdist function. It will fit a large variety of functional forms.


Show 1 older comment
the cyclist
the cyclist on 11 Jan 2019
Use the pdf function, with the pd input.
% Set seed for reproducibility
rng default
% Generate poisson-distributed data.
x = poissrnd(5,10000,1);
% Fit a poisson distribution
pd = fitdist(x,'poisson');
% Calculate the theoretical PDF from the fit parameters
x_range = 0:10;
probability_predicted = pdf(pd,x_range);
% Plot histogram and fit
hold on
h = plot(x_range,probability_predicted,'.-');
Andrés F Vásquez
Andrés F Vásquez on 4 Dec 2019
Using this script as base, how could I plot also certain basic statistics such as mean, median, mode, and std. deviation (including legends in the chart)?
the cyclist
the cyclist on 5 Dec 2019
I'm going to assume you know how to get the values of the statistics. (If not, just google the statistic name along with matlab and you will find that.)
For adding them to the plot, here are a few commands that you could find useful:
  • annotation -- add a wide variety of annotations (including textboxes) to a plot
  • text -- add text to a plot; not as versatile as annotation, but simpler
  • legend -- add legend
  • sprintf -- convert a numerical variable to a string, so that it can be used in the above commands

Sign in to comment.

More Answers (0)