# CDF values are on a scale of 0 to 1, how to scale?

10 views (last 30 days)
Macy on 15 Feb 2023
Commented: Vinayak Choyyan on 16 Feb 2023
Hello,
I made a normal fit distribution for some data called "actual_values". The plot came out fine.
Now how do I display the values of the normal fit distribution? I want to display the 10 numbers predicted by the normal fit distribution. And these 10 values, as you can see from the plot, should be similar to the actual values. However when I output cdf(normalfit, actual_values), I get the values but they are on a scale of 0 to 1. How do I scale the cdf values? For example, the max value should be near 2310.
I think also I am thinking about this the wrong way, the "cdf(normalfit, actual_values)" looks like it is giving me values on the y-scale, and I need the corresponding x-values.
Table = readtable("practice3.xlsx");
actual_values = Table.values;
actual_values = sort(actual_values);
normalfit = fitdist(actual_values,'Normal'); % fit the normal distribution to the data
cdfplot(actual_values); % Plot the empirical CDF
x = 0:2310;
hold on
plot(x, cdf(normalfit, x), 'Color', 'r') % plot the normal distribution
hold off
grid on
cdf(normalfit, actual_values) %How do I scale the cdf values to the actual values? Or how can I extract them from the plot?
ans = 10×1
0.1530 0.1623 0.2616 0.2701 0.3051 0.4251 0.6078 0.6274 0.9307 0.9699
actual_values
actual_values = 10×1
50 80 350 370 450 700 1060 1100 2000 2310
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Answers (1)

Vinayak Choyyan on 15 Feb 2023
Hello Macy,
As per my understanding, you are looking for the X axis values corresponding to Y axis values in ‘cdfplot’.
You can use
h = cdfplot(x)
which returns a handle of the empirical cdf plot line object. You can use ‘h’ to query or modify properties of the object after you create it. You can query it by using
h.XData
to get the X axis values. Here is and example code for the same.
Table = readtable("practice3.xlsx");
actual_values = Table.values;
actual_values = sort(actual_values);
normalfit = fitdist(actual_values,'Normal'); % fit the normal distribution to the data
[h,stats] =cdfplot(actual_values); % Plot the empirical CDF
x = 0:2310;
hold on
plot(x, cdf(normalfit, x), 'Color', 'r') % plot the normal distribution
hold off
grid on
h.XData
ans = 1×22
-Inf 50 50 80 80 350 350 370 370 450 450 700 700 1060 1060 1100 1100 2000 2000 2310 2310 Inf
h.YData
ans = 1×22
0 0 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5000 0.6000 0.6000 0.7000 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000
I hope this resolves the issue you are facing. If you would like to read more about ‘cdfplot’, please check out the following documentation Empirical cumulative distribution function (cdf) plot - MATLAB cdfplot - MathWorks India
##### 2 CommentsShow NoneHide None
Macy on 15 Feb 2023
This does not give the appropriate values in return. The cdf plot is the red line, I need those x-values for each point that corresponds to the empirical data (so I can calculate R^2).
Vinayak Choyyan on 16 Feb 2023
Hi Macy,
The red line is generated by this line in your code
plot(x, cdf(normalfit, x), 'Color', 'r')
You can verify this by commenting out the above line and seeing only the blue line.
The X axis values are in the variable ‘x’ which you created. Hence the ‘x’ values would be
x = 0:2310
And the corresponding Y axis values are given from
cdf(normalfit, x)
I hope this does resolve the issue you were facing.

Sign in to comment.

### Categories

Find more on Logistic Distribution in Help Center and File Exchange

R2022b

### Community Treasure Hunt

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

Start Hunting!