Tuesday, December 13, 2011
MUMBAI UNIVERSITY ENGINEERING NOTES - MU | ENGINEERING | SYLLABUS | NOTES
by Unknown |
MUMBAI UNIVERSITY ENGINEERING NOTES - MU | ENGINEERING | SYLLABUS | NOTES
2011-12-13T21:25:00-08:00 Unknown Comments
|
Sunday, November 27, 2011
Kolmogorov-Smirnov Test
by Unknown |
Kolmogorov-Smirnov Test
2011-11-27T04:33:00-08:00 Unknown c++|Kolmogorov-Smirnov Test|programs|RANDOM NUMBER GENERATION|Test for Random Numbers|Testing for Uniformity| Comments
|
RANDOM NUMBER GENERATION
Test for Random Numbers
Test for Random Numbers
Testing for Uniformity
Refer : Kolmogorov-Smirnov Goodness-of-Fit Test for more detail explanation.
Q) Write a program for implementation of Testing for Uniformity in Kolmogorov-Smirnov Test using C++ .
ANS.
/* Program for Kolmogorov-Smirnov Test */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,i;
float r[100];
float cvalue,d,dplus,dminus,tplus,tminus;
dplus=0;
dminus=0;
cout<<"enter critical value";
cin>>cvalue;
cout<<"please enter number of values";
cin>>n;
for(i=0;i<n;i++)
{
cin>>r[i];
tplus=float((i+1)/n)-r[i]);
tminus=r[i]-float(i/n);
if(tplus>dplus)
{
dplus=tplus;
}
if(tminus>dminus)
{
dminus=tminus;
}
}
if(dplus>dminus)
d=dplus;
else
d=dminus;
cout<<d;
if(d<cvalue)
cout<<"uniform distribution is not rejected"<<endl;
else
cout<<"uniform distribution is rejected"<<endl;
getch();
}
//output:
Enter critical value 15
Please enter number of values
2
5
6
uniform distribution is not rejected
Runs Up and Runs Down
by Unknown |
Runs Up and Runs Down
2011-11-27T04:18:00-08:00 Unknown c++|DWM.BI|programs|RANDOM NUMBER GENERATION|Runs Up and Runs Down|Testing for Independence| Comments
|
RANDOM NUMBER GENERATION
Test for Random Numbers
Test for Random Numbers
Testing for Independence
Runs Up and Runs Down
Q) Write a program for implementation of Testing for Independence in Runs Up and Runs Down using C++ .
ANS.
/* Program for Runs Up and Runs Down */#include<iostream.h> #include<math.h> int main() { float N[10]; int n, count=0,1; int c[10]; float mean , variance, variancesq, z0, za, z; cout<<"\n Enter Critical Value: "; cin>>a; cout<<"\n Enter value of za/2: "; cin>>za; cout<<"\n Enter number of nos. : "; cin>>n; cout<<"\n Enter the nos.: "; for(i=0;i<n;i++) { cin>>N[i]; } for(i=0;i<n-1;i++) { if(N[i]<N[i+1]) { cout<<"+"; c[i]=1; } else { cout<<"-"; c[i]=0; } } for(i=0;i<n-1;i++) { if(c[i]!=c[i+1]) count++; } cout<<"\n No of Runs="<<count<<"\n"; mean=(2*n-1)/3; variancesq=(16*n-29)/90; variance=sqrt(variancesq); z0=(a-mean)/variance; if((za<z0)&&(z0<(0-za))) cout<<"\n The numbers are independent"; else cout<<"\n The numbers are auto-correlated and not independent"; return 0; } //OUTPUT: Enter Critical Value: 0.05 Enter value of za/2: 1.96 Enter number of nos.10 Enter the nos. 0.15 0.27 0.37 0.10 0.50 0.60 0.80 0.70 0.59 -++-+++-- No of Runs=5 The numbers are auto-correlated and not independent