CDF values are on a scale of 0 to 1, how to scale?
7 ビュー (過去 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!