Jainendra Sharma
#include
MCA/4531/10
#include
#include
double fact(int n)
{
if(n<=0) return 1;
else return n*fact(n-1);
}
double geomean(int x,double p,double q)
{
if(x>0)
return pow(q,x-1)*p;
else
return 0;
}
double weibpdf(int x, double v, double a, double b)
{
int n1,p1,q1;
if(x==0)
return fact(n1)/(fact(x)*fact(n1-x))*pow(p1,x)*pow(q1,n1-x);
else
return 0;
}
double poisson(int x, double a)
{
if(x<0 font="font">0>
return 0;
else
{
return (exp(-a)*pow(a,x))/fact(x) ;
}
}
double binomial(int n,double p,int r)
{
return fact(n)/(fact(n-r)*fact(r))*pow(p,r)*pow(1-p,n-r);
}
void main()
{
int ch;
double p,q,v,a,b;
int x,n;
clrscr();
do
{
printf("\nExit.");
printf("\nGeometric Mean.");
printf("\nWeibull Distribution.");
printf("\nPoisson Distribution.");
printf("\nBinomial Distribution.");
printf("\nEnter your choice => ");
scanf("%d",&ch);
if(ch==1)
{
printf("\n\tEnter the value of x,p,q => ");
scanf("%d%lf%lf",&x,&p,&q);
printf("\n\tGeometric Mean = %lf",geomean(x,p,q));
}
else if(ch==2)
{
printf("\n\tEnter the value of x,v,a,b => ");
scanf("%d%lf%lf%lf",&x,&v,&a,&b);
printf("\n\tWeibull pdf, f(%d) = %lf",x,weibpdf(x,v,a,b));
printf("\n\n\tWeibull cdf, F(%d) = %lf",x,weibcdf(x,v,a,b));
}
else if(ch==3)
{
printf("\n\tEnter the value of x,a => ");
scanf("%d%lf",&x,&a);
printf("\n\tPoisson Distribution, p(%d) = %lf",x,poisson(x,a));
}
else if(ch==4)
{
printf("\n\tEnter the value of x,p,q,n => ");
scanf("%d%lf%lf%d",&x,&p,&q,&n);
printf("\n\tBinomial Distribution, p(%d) = %lf",x,binomial(x,p,n));
}
}while(ch!=0);
getch();
}
Comments