Geometric mean with logarithmically spaced data?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This is partly a Matlab question, partly conceptual. I generated three vectors with logarithmically spaced numbers using logspace. If I want to average the first element in the three vectors, then separately the second element, and so on, should I take the arithmetic or geometric mean? If the latter, how do I do this?
1 commentaire
Stephen23
le 12 Juil 2022
Modifié(e) : Stephen23
le 12 Juil 2022
"If I want to average the first element in the three vectors, then separately the second element, and so on, should I take the arithmetic or geometric mean?"
You gave no information in your question that helps us to understand what you need those means to achieve or how you will use them. In the absence of an such information, are you looking to understand different types of mean?:
Réponse acceptée
DGM
le 12 Juil 2022
Modifié(e) : DGM
le 12 Juil 2022
"how do I do this?"
% three vectors:
A = logspace(0,2,10);
B = logspace(0,1.9,10);
C = logspace(0.2,2,10);
% put them in an array
allvecs = [A; B; C]
% take the arithmetic mean
avg = mean(allvecs,1)
% take the geometric mean
gmn = geomean(allvecs,1)
1 commentaire
John D'Errico
le 12 Juil 2022
Modifié(e) : John D'Errico
le 12 Juil 2022
I'm confused as to the question. Is it asking if you should use a geometric mean or an arithmetic mean? Surely that is your choice? @DGM tells you how to compute either, but there is no truly correct way to do something that only you know why you are doing it.
Another simple way to form a set of several geometric sequences is::
S = 2.^([0;0;0] + [1;2;3].*linspace(0,1,10))
I'll let you figure out how I generated them..
Now, since I carefully chose the rate constants, a property of the geometric mean is that it will return the middle sequence.
geomean(S,1)
Do you see that the geometric mean here just reproduced the middle one?
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!