How can I save "alpha" and "beta" parameters as double using fitdist command?
Show older comments
Hi everyone,
I'm having problems when trying to save "alpha" and "beta" parameters when using the fitdist command.

CC is a vector of 1000 elements, I need to save a and b. I need this because I have 50 vectors for which I need to find the beta distribution that better represent my distribution of 1000 elements, and I would like to use a loop to automatically save in a .txt or .xlxs file all those a and b values. but PD is a betaDistribution object and I encounter some errors when trying to take a and b out of PD. In the Beta probability distribution object Matlab page, I can't find the command to save a and b. Of course one option would be to save them manually.
Thanks in advance,
Have a nice day!
Accepted Answer
More Answers (1)
Image Analyst
on 29 May 2023
Try this (untested):
% Preallocate a and b column vectors. One element for each file.
a = zeros(50, 1);
b = zeros(50, 1);
% Get distributions from 50 files.
for k = 1 : 50 % for all 50 files
% Get distribution for this file
pd = fitdist(x/max(x),'Beta')
% Extract a and b values from the output and store them in column vectors.
a(k) = pd.a
b(k) = pd.b
end
% Create table from the two column vectors:
t = table(a, b, 'VariableNames', {'a', 'b'})
% Write table out to disk:
writetable(t, 'ab.xlsx')
Adapt as needed.
1 Comment
Luca Morena
on 30 May 2023
Categories
Find more on Univariate Discrete Distributions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!