How to compute Expectation in MatLab?
42 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ethen
el 25 de Sept. de 2014
Hello Guys,
I need to compute E{x^4} in MatLab (x is vector). Can it be done by taking the mean value of x^4 (each element of x exponent 4).
Thanks for the help. Regards
0 comentarios
Respuesta aceptada
Stephen23
el 25 de Sept. de 2014
Editada: Stephen23
el 25 de Sept. de 2014
Many basic operators in MATLAB are treated as matrix operations, including multiplication , division ,and power operators.
When you wish to perform the same operation element-wise, then you can use the element-wise syntax. For example matrix multiplication is A*B, whereas multiplication of corresponding array elements is A.*B .
x.^4
which operates on the whole vector at once. Handy! You might like to read this too:
0 comentarios
Más respuestas (1)
Star Strider
el 25 de Sept. de 2014
That is how I would do it, using element-wise exponentiation:
Ex4 = mean(x.^4);
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!