How to fit a (left) skewed distribution

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 Comment

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.

Sign in to comment.

 Accepted Answer

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

6 Comments

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.
If you attach mydata in a .mat file, maybe someone will show you.
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')
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!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!