MATLAB: Graph one trace of the sample mean of the poisson (1) random variable. Calculate (using a central limit theorem approximation) and graph the corresponding 0.9 confidence interval estimate.

poisson graphpoisson random variablespoissonrnd

Hi,
I'm trying to graph for the above question, using examples found in probabilities and stochastic processes 3rd edition examples 10.13 and 10.14 I came up with the following function, but I'm having problems with the matrix dimensions matching.
function M=pms(n) % Function name poisson's mean sequence
x=poissrnd(1,1,n); % Create a poisson rv with lambda = 1
MN=cumsum(x)./((1:n)'); % MN= vector Mn(x)

nn=(10:n)'; MN=MN(nn); % Create an n matrix with which to get the STD
std90=(1.65)./sqrt(nn); % Create the STD lambda/sqrt(n)
y=[MN MN-std90 MN+std90]; % consolidate y into MN, MN-STD, and MN+STD
plot(nn,y) %Plot
The error I'm getting is
Error using ./
Matrix dimensions must agree.
Error in pms (line 3)
MN=cumsum(x)./((1:n)'); % MN= vector Mn(x)
Thanks.

Best Answer

Remove the transpose (') operator:
MN=cumsum(x)./((1:n)); % MN= vector Mn(x)
Related Question