# February 2010 Master of Computer Application (MCA) – Semester 3 MC0074 – Statistical & Numerical Methods using C

++
Assignment Set – 2

1. Briefly explain the concept of Bernoulli’s process
Ans –

The Bernoulli Process Consider a sequence of independent Bernoulli trials and let the discrete random variable Yi denote the result of the ith trial, so that the event [Yi =1] denotes a success on the ith trial and the event[Yi = 0] denotes a failure on the ith trial. Further assume that the probability of success on the ith trial, P[Yi = 1], is p, which is independent of the index i. then {Yi|i=1,2…n} is a discrete state, discrete parameter, stochastic process, which is stationary in the strict sence. Since the Yi’s are mutually independent, the above process is an independent process known as the Bernoulli process. Since Yi is a Bernoulli random variable, we recall that E[Yi] = p E[Yi2] = p Var[Yi] = p(1-p) and GYi(z) = (1-p)+pz based on the Bernoulli process, we may form another stochastic process by considering the sequence of partial sums{Sn|n=1,2…}, where Sn=Y1+Y2+…+Yn. by rewriting Sn=Sn1+Yn, it is not difficult to see that {Sn} is a discrete state, discrete parameter Markov process, since P(Sn =k|Sn-1 = K) = P(Yn=0) 1-p And P(Sn=K|Sn-1 = K-1) = P(Yn =1) =p Clearly P(Sn=K) = (n) pk(1-p)n-k = (k) E[Sn]=np Var[Sn]=np(1-p) and GSn(z) = (1-p+pz)n

Define the discrete random variable T1, called the first order interarrival time, to be the number of trials up to and including the first success. T1 is geometrically distributed so that P(Ti=i) = p(1-p)i-1, i=1,2… E(T1)=1/p Var(T1) = 1-p/p2 and [G T1(z) = zp/1-z(1-p)] Similarly [G Tr(z) =[ zp/1-z(1-p)]r]

2. If
2 3

is approximated by 0.667, find the absolute

and relative errors
Ans –

absolute error = 0.001666666... relative error = 0.0024999 approx

3. Write a program in C++ language for the addition of two matrices.
Ans – #include<iostream.h> #include<conio.h> void main() { int ch,a[10][10],b[10][10],c[10][10],m,n,o,p,i,j; clrscr(); cout<<"Enter row no. and column no. of matrix 1: ";cin>>m>>n; cout<<"Enter row no. and column no. of matrix 2: ";cin>>o>>p; if (m!=o||n!=p) cout<<"Matrix cannot be added"; else { cout<<"\nEnter elements of matrix 1..\n"; for (i=0;i<m;i++) for (j=0;j<n;j++) cin>>a[i][j]; cout<<"\nEnter elements of matrix 2..\n";

for (i=0;i<o;i++) for (j=0;j<p;j++) cin>>b[i][j]; for (i=0;i<m;i++) for (j=0;j<n;j++) c[i][j]=a[i][j]+b[i][j]; cout<<"\nMatrix after addition..\n"; for (i=0;i<m;i++) { } } } } for (j=0;j<n;j++) cout<<c[i][j]<<" "; cout<<"\n";

4. Find a real root of the equation x3 – 4x – 9 = 0 using the bisection method
Ans – First Let x0 be 1 and x1 be 3 F(x0) = x3 – 4x -9 =1–4–9 = -12 < 0 F(x1) =27 – 12 – 9 =6>0 Therefore, the root lies between 1 and 3 Now we try with x2 =2 F(x2) = 8 – 8 – 9 = -9 < 0 Therefore, the root lies between 2 and 3 X3 = (x1+x2)/2 =(3+2)/2 = 2.5 F(x3) = 15.625 – 10 – 9 = - 3.375 < 0 Therefore, the root lies between 2.5 and 3 X4 = (x1+x3)/2 = 2.75

5. Find the cubic polynomial which takes the following values y(0) = 1, y(1) = 0, y(2) = 1 and y(3) = 10 . Hence obtain the value of y(0.5).
Ans –

y(x) = 1 - 2 x2 + x3 Check: y(0) = 1, y(1) = 0, y(2) = 1 and y(3) = 10 y(0.5) = 0.625

6. Evaluate

using Trapezoidal rule with h = 0.2.

∫ 1 + x2
0

1

dx

Hence determine the value of π.
Ans-

0.7837,3.1349