Is there a reason why Triangular is not an option in fitdist?

2 Ansichten (letzte 30 Tage)
One can make triangular dists via makedist, but why not automate the mu and sigma calc. That way a user can toggle between options such as 'Normal' and 'Triangular' in the fitdist command more easily.

Akzeptierte Antwort

John D'Errico
John D'Errico am 11 Okt. 2022
Bearbeitet: John D'Errico am 11 Okt. 2022
Is there a GOOD reason why not? Probably not, but then I don't expect a triangular distribution is in high demand either. Could you use maximum likelihood techniques to estimate the parameters of a triangular distribution? I don't see why not, though there may be some numerical issues I don't immediately see. There are always things that sneak up and bite you in the ... More likely, I asssume it is not in there out of parsimony. Why write code nobody will need?
IF you truly, REALLY need it, then you could send in a feature request. Of course, don't expect it to appear next week. More likely a year or several years down the line, as this certainly would not be a high priority thing for them to do, and there are only so many resources they have to write code, so many person-hours they have available.
So, IF you desperately need it now, you would need to write the code yourself to estimate those parameters. Sorry 'bout that. Are you talking about a simple symmetric triangular distribution? That would be easy enough. A skewed one would take a little more effort, but not that much.
  2 Kommentare
Matt Weber
Matt Weber am 11 Okt. 2022
Thanks for the reply. I mainly wanted to make sure I wasn't misunderstanding how to use fitdist. Triangular might be more used that 'Birnbaum-Saunders', but nothing against the developers!
John D'Errico
John D'Errico am 11 Okt. 2022
Bearbeitet: John D'Errico am 11 Okt. 2022
A quick check for myself, and I do not see triangular in there.
I imagine the coding squad for the stats TB saw no real need for it. I'd have probably made the same choice. Triangular distributions always seemed to be one of those things that were good for student homework assignments, but not much more. :-) I can't say I'm not wrong in that perception, and I'd be happy to be proven wrong. As it is, in the codes I have written, I have often been surprised to see someone have a use for an option I put in there just for fun (pure fluff in my eyes), never expecting it to be the perfect solution for somone out there.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 12 Okt. 2022
Are triangular distributions of actual things in nature something that actually occurs? If so, where/when? To me it seems like something that may only be wanted as something like a homework question. Sure triangular/sawtooth waveforms happen in nature but distributions or histograms? I don't know of any. Perhaps you do. If so, tell me where.
  8 Kommentare
Image Analyst
Image Analyst am 4 Jan. 2023
@Paul and @Frank Yes that is very true. The distribution of the sum of two variables is the convolution of the distribution of the two individual variables. (I learned this in my statistical optics grad school class - not sure how many people know this.) So convolving two rect functions will give a triangle. If you sum 3 variables you need to convolve it with a third rect function and the distribution becomes more rounded. As you convolve in more and more functions it becomes very Gaussian looking very quickly. This means that the distribution of a sum of many random variables with uniform distribution is Gaussian. I think the Central Limit Theorem is somehow involved in the proof. Here is code illustrating it
% Demo by Image Analyst
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 short g;
format compact;
fontSize = 22;
markerSize = 15;
pulseWidth = 111;
pulse = [zeros(1, pulseWidth), ones(1, pulseWidth), zeros(1, pulseWidth)]
subplot(6, 1, 1);
plot(pulse, 'b-', 'LineWidth', 2)
title('Original distribution of a single variable', 'FontSize',fontSize)
grid on;
newPulse = pulse;
% Add together more random variables and
% you'd get the convolution of their individual PDFs.
for k = 1 : 5
newPulse = conv(newPulse, pulse, 'full');
subplot(6, 1, k+1);
plot(newPulse, 'b-', 'LineWidth', 2)
grid on;
caption = sprintf('Distribution after summing %d variables', k+1);
title(caption, 'FontSize',fontSize)
end
The funny thing is, is that the shapes of the individual PDFs usually doesn't matter. It tends towards a Gaussian, as more variables are added, no matter the shape.
Paul
Paul am 4 Jan. 2023
The distribution of the sum of two independent variables is the convolution of the distribution of the two individual variables.
For continuous RV's, I'd replace "distribution" with "density function," but maybe that's being pedantic.
If interested, this reference derives a closed form expression for the pdf of the sum of uniform RV's:
S. M. Sadooghi-Alvandi · A. R. Nematollahi, R. Habibi, "On the distribution of the sum of independent uniform random variables"

Melden Sie sich an, um zu kommentieren.

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by