Azzera filtri
Azzera filtri

cumulative probability curve as a percent

18 visualizzazioni (ultimi 30 giorni)
Sonia Wiemann
Sonia Wiemann il 22 Set 2014
Risposto: Guillaume il 22 Set 2014
I have a data set that I want to plot a cumulative probability curve (as a percent). The values are all amplitudes of a signal. I need the Y axis to be cumulative probability (0:1) and the x axis to be amplitude. I am very new to matlab and don't have a lot of programming experience so any help is greatly appreciated and must be explained very clearly. I can get lost in the code at times.
Thanks in advance,

Risposte (2)

Guillaume
Guillaume il 22 Set 2014
You can calculate the distribution of your data using matlab's histogram function hist (or histc). For the bin, you would probably use a vector of values from the min to the max of your data with a small step (unit step, maybe):
step = 1; %or whatever step you want
bins = min(data):step:max(data);
dist = hist(data, bins);
You can then normalise the distribution to 0:1 by dividing by the sum of the histogram
ndist = dist / sum(dist);
Finally to get the cumulative distribution, you use cumsum:
cdist = cumsum(ndist);
plot(bins, cdist);

Star Strider
Star Strider il 22 Set 2014
Modificato: Star Strider il 22 Set 2014
I would start with hist and its friends (linked to at the end of the documentation). You can calculate the cumulative distribution from the results it gives you.
If you want to fit a distribution (probability density function) to it and you have the Statistics Toolbox, histfit and its friends will help you define it. You can then calculate and plot the cumulative distribution function from the parameters it estimates. That is a more analytic approach.

Community Treasure Hunt

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

Start Hunting!

Translated by