How to find cumulative distribution function from a given data set(vector)

clc
clear all
rng('default') % For reproducibility
y = evrnd(0,3,100,1);
[a,s]=cdfplot(y);
In this "cdfplot "directly plots the cdf graph, that too is repeats the each number then finds cdf.
But I want the cdf vector.
Can someone help me please?

 Akzeptierte Antwort

Hi Shankul,
I'm not sure what "I want the cdf vector" means. If that means the data that forms the cdf plot on the graph, then the data can be obtained from the XData and YData properties of a:
rng('default') % For reproducibility
y = evrnd(0,3,100,1);
[a,s]=cdfplot(y);
plot(a.XData,a.YData)
If that's not what you want, can the Question be clarified?

3 Kommentare

Shankul Saini
Shankul Saini am 24 Nov. 2022
Bearbeitet: Shankul Saini am 24 Nov. 2022
okay thanks @Paul but if you seem only 100 elements were there in y but in cdfplot we have 200 elements and in that each element is repeated once.
And also +inf and -inf are added in starting and last. How can i get plot which has only original number of elements which in this case is 100.
And one more thing, can i get this xdata and ydata without plotting, i don't need the plot i just need data.
Mabye ecdf is what you're looking for?
rng('default') % For reproducibility
y = evrnd(0,3,100,1);
[a,s]=cdfplot(y);
[f,x]=ecdf(y);
hold on
plot(x,f)
whos x f y
Name Size Bytes Class Attributes f 101x1 808 double x 101x1 808 double y 100x1 800 double
The extra point in x and f is the first where x(1) = x(2) and f(1) = 0;
Okay yeah, that seems fine. Thanks paul

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by