Effacer les filtres
Effacer les filtres

How can I calculate the sample mean and sample variance

19 vues (au cours des 30 derniers jours)
Ihor
Ihor le 4 Déc 2022
I have a pseudo-random matrics M, sizes K-by-N. How can I calculate the sample mean and sample variance:
1) for each column,
2) for the whole matrix?

Réponse acceptée

RAGHUNATHRAJU DASHARATHA
RAGHUNATHRAJU DASHARATHA le 4 Déc 2022
A per my understanding you want to calculate mean and variance for each column and whole matrix.
I'll demonstrate it using below example
a=randi(10,3) % generates pseudo random matrix
a = 3×3
3 2 10 5 10 3 8 4 3
%Mean and Variance for each column
[V,M]=var(a)
V = 1×3
6.3333 17.3333 16.3333
M = 1×3
5.3333 5.3333 5.3333
%Mean and Variance for whole matrix
[b,c]=var(a,0,"all")
b = 10
c = 5.3333
for further more go through this link

Plus de réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping 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!

Translated by