Calculate the population mean of several probability distributions
Ältere Kommentare anzeigen
Hi all,
I would like to calculate the population average of different proability distirbutions (n=26) with a normal distribution. For each subject, I fitted a single normal probability distribution using the code below (in a loop for each subject). The data are angles from a motor task. I receive 26 different objects with the results including mu, sigma etc (I attached an example from one subject).
Now, I would like to calculate the average proability distribution of these 26 subjects. Does anyone know how to do it? Using the command "mean" does not work. An alternative approach would be to pool the data from all 26 subjects prior to the fitting and only calculate the probaility distribution for this one population file.
Any information is appreciated. Thanks in advance,
Patrick
for i= 1:26
pd_correct(i,:) = fitdist(Change_after_correct{i,:}(:,1),'Normal');
end
Antworten (1)
Du kannst das direkt in der Schleife machen, in dem Du die benötigten Felder der struct ansprichst und die interessierenden Werte in einem seperaten Vektor speicherst. Mit dem kanst Du dann unkompliziert arbeiten:
% 5x 20 Zufallszahlen als Spielmaterial
A = rand(20,5);
% Preallocation
all_mean_values = zeros(1,5);
for i= 1:5
pd_correct(i,:) = fitdist(A(:,i),'Normal');
% Alle Mittelwerte einsammeln und in Array speichern
all_mean_values(i) = pd_correct(i).mean;
end
% Zeige Vektor der Mittelwerte
disp(all_mean_values)
Das geht natürlich auch im Nachgang mit einer zweiten Schleife, falls die Neuberechnung zu aufwändig ist.
5 Kommentare
Patrick WIegel
am 21 Okt. 2020
Patrick WIegel
am 21 Okt. 2020
Stephan
am 21 Okt. 2020
Um eine Frage abzuschließen, macht es Sinn eine zufriedenstellende Antwort zu akzeptieren. Wenn Deine eigene Lösung besser ist, poste sie als Antwort und akzeptiere sie. Dann können andere mit ähnlichen Problemen den Thread besser finden.
Jeff Miller
am 21 Okt. 2020
Just be aware that the notion of an "average probability distribution" is not uniquely defined. For example, instead of averaging the estimated standard deviations (sigma values) you could have averaged the estimated variances (sigma^2 values) and taken the square root of that as the sigma for the average distribution. This would give a (possibly quite) different result and is probably at least as theoretically defensible as averaging sigmas.
Patrick WIegel
am 22 Okt. 2020
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!