E(X) AND V(X) AND MOMENTS OF PROBABILITY DISTRIBUTION FUNCTION> Scilab

Applied Mathematics

E(X) AND V(X) AND MOMENTS OF PROBABILITY DISTRIBUTION FUNCTION> Scilab


X=[0 1 2 3 4]
PX=[0.41 0.41 0.15 0.02 0.01]
EX=0,VX=0,M1=0,M2=0,M3=0,M4=0,s1=0,s2=0,s3=0;
for(i=1:5)

  EX=EX+(X(i)*PX(i));
  s1=s1+X(i)*X(i)*PX(i);
  s2=s2+X(i)*X(i)*X(i)*PX(i);
  s3=s3+X(i)*X(i)*X(i)*X(i)*PX(i);
end
disp("The Expected value")
EX
VX=s1-EX*EX;
disp("The Variance is");
VX
disp("The first  moment is");
M1=EX;
EX
disp("The second  moment is");
M2=VX;
VX
M3=s2-3*M1*M2+2*EX*EX*EX;
disp("THe value of moment is")
M3
M4=s3-4*EX*s2+6*EX*EX*s1-4*EX*EX*EX*EX+EX*EX*EX*EX;
disp("the fourth moment is")
M4
/*
OUTPUT
 X  =

    0.    1.    2.    3.    4.
 PX  =

    0.41    0.41    0.15    0.02    0.01
 EX  =

    0.
 VX  =

    0.
 M1  =

    0.
 M2  =

    0.
 M3  =

    0.
 M4  =

    0.
 s1  =

    0.
 s2  =

    0.

 The Expected value
 EX  =

    0.81

 The Variance is
 VX  =

    0.6939

 The first  moment is
 EX  =

    0.81

 The second  moment is
 VX  =

    0.6939

 THe value of moment is
 M3  =

    2.166705

 the fourth moment is
 M4  =

    1.9734084
                 */

Comments

Popular posts from this blog

Intermediate Code Generation > C Program