Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to implement E[x] in matlab?

Status
Not open for further replies.

bee

Full Member level 2
Joined
Nov 29, 2003
Messages
135
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,298
Activity points
883
matlab expectation

can anyone plz tell me how to implement E[x] in matlab. E[.] is the expectance.
Also tell me what exectly it is?

Waiting....
 

expectation matlab

you can use the matlab instruction: mean(x).

MEAN Average or mean value.
For vectors, MEAN(X) is the mean value of the elements in X. For
matrices, MEAN(X) is a row vector containing the mean value of
each column. For N-D arrays, MEAN(X) is the mean value of the
elements along the first non-singleton dimension of X.

MEAN(X,DIM) takes the mean along the dimension DIM of X.

Example: If X = [0 1 2
3 4 5]

then mean(X,1) is [1.5 2.5 3.5] and mean(X,2) is [1 ; 4]
 

ensemble average matlab

Hi

let f(x) be the PDF of the discrete random variable X=(x1, ..., xN) , the the mathematical expectation of x is defined as


E[x]=∑xif(xi)

(where summation is carried out from i=1 to N)

this equation can simply be written as a for loop in Matlab or any other programming language.

regards
 

matlab e

Hi,

Expectation of X computes the ensemble average of X. This can be computed using function mean(X)
 

expectation in matlab

actually,

mean() function do the time average!

the definition of E(.) is E[x]=∑xif(xi)! so amihomo is right!!!

we often use time average instead of ensemble average if the random process
is ergodic!!
 

calculation of expectation using matlab

simply use mean function
as mean(x), if x is 2-dim then the mean function calculat mean for each colum
 

% i m explaining this taking an example of throwing a dice:

% Code for finding the expectaion of the given experiment:

clc;
clear all;
close all;

p=[1/6 1/6 1/6 1/6 1/6 1/6];
ln=length(p);
samples=[1 2 3 4 5 6];

expec=0;
for i=1:ln

expec=expec+(p(i)*samples(i));
end

disp(['For the outcome of throwing a dice as: ', num2str(samples)]);
disp(['with probabilities: ' num2str(p)]);
disp(['The expected value of throwing a dice is: ', num2str(expec)]);
-------------------
it works, check it out!!!
reply back!!!
rpborse@gmail.com
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top