필터 지우기
필터 지우기

I have 2 datasets each containing 1000 observations. I want to calculate quantiles of each dataset separately and then plot a qqplot between them. How to do? steps required

조회 수: 5 (최근 30일)
I have 2 datasets each containing 1000 observations. I want to calculate quantiles of each dataset separately and then plot a qqplot between them. How to do? steps required

답변 (1개)

Ayush Anand
Ayush Anand 2023년 12월 12일
Hi Payel,
You can use the “quantile” function in MATLAB to calculate the quantiles for each dataset, specifying the number of quantiles or the specific probabilities you want to calculate. Here’s an example of how you could do the same:
%Load your datasets as data1 and data2. Two sample datasets are shown below
% data1 = randn(1000,1); % Normally distributed random data
% data2 = exprnd(1,1000,1); % Exponentially distributed random data
% Step 2: Calculate the quantiles for each dataset
% You can specify the probabilities for which you want to calculate the quantiles
% For example, to calculate deciles you can use 0.1:0.1:0.9
probabilities = 0.1:0.1:0.9;
quantiles1 = quantile(data1, probabilities);
quantiles2 = quantile(data2, probabilities);
% Step 3: Create the Q-Q plot to compare the quantiles of the two datasets
qqplot(quantiles1, quantiles2);
%Customize the plot
grid on;
xlabel('Quantiles of Dataset 1');
ylabel('Quantiles of Dataset 2');
title('Q-Q Plot of Dataset 1 vs Dataset 2');
You can refer to the following pages for more information:
  1. https://www.mathworks.com/help/matlab/ref/quantile.html (Official documentation for the “quantile” function in MATLAB)
  2. https://www.mathworks.com/help/stats/qqplot.html (Official documentation for the “qqplot” function in MATLAB)
I hope this helps!

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by