K分布累计分布函数中的超几何函数
#include<iostream.h>
#include<iomanip.h>
double zhishu(double x,int t)
{
if(x==0&&t==0)
return 1;
else
{
double zx=1;
for(int i=1;i<=t;i++)
{
zx=x*zx;
}
return zx;
}
}
double liancheng(double a,int b)
{
if(a==0&&b==0)
return 1;
else
{
double c=1;
for(int k=1;k<=b;k++)
{
c=c*(a+k-1);
}
return c;
}
}
double jiecheng(int a)
{
double c=1;
for(int i=1;i<=a;i++)
{
c=c*i;
}
return c;
}
void main()
{
double a,b,c,x,sum=0,e=0.0000000001;
cout<<"请分别输入超几何函数参数值a,b,c,x,以回车键隔开"<<'\n';
cin>>a>>b>>c>>x;
for(int k=0;k>=0;k++)
{
sum=sum+liancheng(a,k)/liancheng(c,k)*liancheng(b,k)/jiecheng(k)*zhishu(x,k);
if((liancheng(a,k)/liancheng(c,k)*liancheng(b,k)/jiecheng(k)*zhishu(x,k))<=e)
break;
}
cout.precision(20);
cout<<"F("<<a<<","<<b<<","<<c<<","<<x<<")="<<sum<<'\n'<<k<<'\n';
}