Hi,
Currently, I am using the following code to fit distributions to my data:
pd = fitdist(mydata,distribution)
x_values = 1:1:26;
y = pdf(pd,x_values);
plot(x_values,y,'LineWidth',2)
However, as far as I can see all the distributions offered by Matlab are either not skewed or right-skewed. Hence my question: Knowing that my data is left-skewed, how could I fit such a distribution to it?
Thanks

1 commentaire

Kin Sung Chan
Kin Sung Chan le 23 Avr 2020
histfit(mydata/max(mydata), 30, 'beta'); % let's say using bin = 30.
However, even though it can produce a fit, the 'beta' requires your data to be within 0 and 1.

Connectez-vous pour commenter.

 Réponse acceptée

Image Analyst
Image Analyst le 2 Sep 2017

2 votes

Try fitting the max value minus your data. In other words, flip your distribution right to left.

6 commentaires

MiauMiau
MiauMiau le 2 Sep 2017
So you mean to change my distribution to a right-skewed distribution? And then how would I proceed..? Showing a right skewed distribution for an underlying left-skewed dataset is, I assume, quite confusing for the audience.
Image Analyst
Image Analyst le 2 Sep 2017
If you attach mydata in a .mat file, maybe someone will show you.
MiauMiau
MiauMiau le 2 Sep 2017
That would be very nice:) It is attached
It looks fine to me
% Initialization steps.
% clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
storedStructure = load('mydata.mat')
mydata = storedStructure.mydata';
subplot(2, 1, 1);
plot(mydata)
grid on;
title('Original Data', 'FontSize', fontSize);
subplot(2, 1, 2);
hObj = histogram(mydata, 10)
grid on;
title('Histogram of Original Data', 'FontSize', fontSize);
distribution = 'Lognormal';
pd = fitdist(mydata,distribution)
x_values = linspace(0, max(mydata), 100);
y = pdf(pd,x_values);
% subplot(2, 2, 3);
hold on;
plot(x_values,y,'LineWidth',2)
title('Original Data', 'FontSize', fontSize);
legend('Data', 'Fitted Distribution');
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
Maria Amr
Maria Amr le 2 Fév 2021
I have the same problem but my data are right skewed. Would you please direct me how to fit a right skewed distributions? Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by