Filter löschen
Filter löschen

Drawing a 1-CDF Graph

9 Ansichten (letzte 30 Tage)
See Kai Xiang
See Kai Xiang am 11 Okt. 2021
Beantwortet: Neelanshu am 27 Feb. 2024
Hi everyone, I want to ask how do I draw a 1-cdf graph on matlab?
I have a set of data and I have already plotted a regular cdf using ecdf(data set). However, when I simply put 1-ecdf(data set), matlab returns me a vector. I have also tried plot(X,1-ecdf(data set)) but it looks completely wrong. X is just a vector I used for my data points. Can anyone help me out?
F=SGLD_cdf(X,Sigma,r,deta,b)
Y1 = n(1:1529:end,:);
figure(2)
plot(X,F)
hold on
% SGLD_cdf is a function created in another script, while X = 0.1:0.1:max(n) where n is my dataset
ecdf(n)
hold on
legend('Fitted curve','Data Set')
  2 Kommentare
KSSV
KSSV am 11 Okt. 2021
What are dimensions of n? You are getting any error?
See Kai Xiang
See Kai Xiang am 11 Okt. 2021
n is a 261345x1 vector. The above code is able to generate out 2 CDF curves nicely with no issues. However, what I require is a 1-cdf curve, which is essentially a flipped CDF curve.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Neelanshu
Neelanshu am 27 Feb. 2024
Hi See Kai Xiang,
I understand that you are looking for a way to plot 1-CDF of the data.
To plot the 1-CDF, you can utilize the function values and x intervals obtained from MATLAB's "ecdf" function. The following MATLAB script demonstrates how to do this:
% Generate some example data, e.g., random numbers from a normal distribution
data = randn(1000, 1);
% Calculate the CDF values and the corresponding x values (sorted data)
[f, x_values] = ecdf(data);
% Calculate the 1-CDF
one_minus_f = 1 - f;
% Plot the 1-CDF and CDF
figure;
ecdf(data) % plots CDF
hold on;
plot(x_values, one_minus_f);
xlabel('Data values');
ylabel('1-CDF/ CDF');
title('CDF plots of the data');
legend('CDF Data', '1-CDF Data')
grid on;
You may refer to the following documentation to learn more about "ecdf" function :
Hope this helps.

Community Treasure Hunt

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

Start Hunting!

Translated by