필터 지우기
필터 지우기

Drawing a 1-CDF Graph

조회 수: 8 (최근 30일)
See Kai Xiang
See Kai Xiang 2021년 10월 11일
답변: nick 2024년 2월 27일
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
KSSV
KSSV 2021년 10월 11일
What are dimensions of n? You are getting any error?
See Kai Xiang
See Kai Xiang 2021년 10월 11일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

nick
nick 2024년 2월 27일
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.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by