概述
include
"stdafx.h"
#include
#include
#include
#define M
0.00001
#define M1
0.000001
#define pi
3.1415926535898
using namespace
std;
double N(double
d) //正态分布函数求解
{ double
Nd;
double t;
double
a=0.33267,a1=0.4361836,a2=-0.1201617,a3=0.9372986;
if(d>0)
{ t=1/(1+a*d);
Nd=1-1/pow(2*pi,0.5)*exp(-d*d/2)*(a1*t+a2*t*t+a3*t*t*t);
}
else if(d<0)
{ t=1/(1-a*d);
Nd=1/pow(2*pi,0.5)*exp(-d*d/2)*(a1*t+a2*t*t+a3*t*t*t);
}
return Nd;
}
double NX(double
y) //正态分布函数求反求x
{ //假设x的值为非负
double
t;
double temp;
double
d,x=0;
double
a=0.33267;
double
a1=0.4361836,a2=-0.1201617,a3=0.9372986;
for(t=0;t<=1;t=0.00001+t)
{
d=(1/t-1)/a;
temp=1-1/pow(2*pi,0.5)*exp(-d*d/2)*(a1*t+a2*t*t+a3*t*t*t)-y;
if(temp
{ x=d;
break;
}
}
return x;
}
//求绝对值
long double abs1(long
double x)
{ long double x1=0;
if(x>0)
x1=x;
if(x<=0)
x1=-x;
return
x1;
}
long double KMV(long
double &zcbdx1,long double &A,long
double gqbdx,long double E, double t,long double r,long double
B)
///gqbdx代表股权波动性,E为股权市场价值,t代表间隔时间,r代表物风险利率,B代表违约点
{ double
Nd2=0,d2=0,d1=0,temp=0,zcbdx=0,A1=0;
//
for(zcbdx=0.0001;zcbdx<=1;zcbdx=zcbdx+0.0001)
{ //d1=d2+zcbdx*pow(t,0.5)=(log(gqbdx*E/zcbdx/N(d1)/B)+(r+0.5*zcbdx*zcbdx)*t)/(zcbdx*pow(t,o.5));
//A=gqbdx*E/N(d1)/zcbdx;
//思路:假设zcbdx已知,求出N(d2)
//
N(d2)=(-E+gqbdx*E/zcbdx)/(B*exp(-r*t));
//根据N(d2)求出d2;再求出d1
//d1=d2+zcbdx*pow(t,0.5);
//f(d1)=d1-(log(gqbdx*E/zcbdx/N(d1)/B)+(r+0.5*zcbdx*zcbdx)*t)/(zcbdx*pow(t,o.5));
//接近0时,即求出zcbdx;
Nd2=(-E+gqbdx*E/zcbdx)/(B*exp(-r*t));
d2=NX(Nd2);
d1=d2+zcbdx*pow(t,0.5);
temp=d1-(log( (gqbdx*E/zcbdx/N(d1))/B)+(r+0.5*zcbdx*zcbdx)*t
)/(zcbdx*pow(t,0.5));
A1=gqbdx*E/zcbdx/N(d1);
//printf("%f,%fn",zcbdx,A1);//输出值,查看具体实现的值
if(temp
{ zcbdx1=zcbdx;
A=gqbdx*E/zcbdx1/N(d1);
break;
}
}
return 0;
}
int _tmain(int argc,
_TCHAR* argv[])
{
//调用正态及正态反函数并验证结果
printf("%fn",N(1));
printf("%fn",NX(N(1)));
long double x,y,x1;
//调用KMV函数的方法
x1=KMV(x,y,0.540072,4062123101,0.74794,0.0277,1967828071);
//输出x,和y的值的方法
return
0;
}
最后
以上就是可靠水杯为你收集整理的c语言软件市场价,[转载]KMV模型中求解资产市场价值和资产价值波动性(C语言)...的全部内容,希望文章能够帮你解决c语言软件市场价,[转载]KMV模型中求解资产市场价值和资产价值波动性(C语言)...所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复