CDF values are on a scale of 0 to 1, how to scale?
9 次查看(过去 30 天)
显示 更早的评论
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?
actual_values
0 个评论
回答(1 个)
Vinayak Choyyan
2023-2-15
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
h.YData
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 个评论
Vinayak Choyyan
2023-2-16
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!