#include
#include
#include
long 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)
{
if(x
return fact(n)/(fact(x)*fact(n-x))*pow(p,x)*pow(q,n-x);
else
return 0;
}
int 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,binom(x,p,q,n));
}
}while(ch!=0);
getch();
return 0;
}
Astha
MCA 4510/09
Comments