#include<iostream>
#include<cmath>
#include <boost/math/distributions/inverse_gaussian.hpp>
#include<random>
using boost::math::inverse_gaussian;
using namespace std;
int main()
{
float currentprice,newprice, riskfreerate, volatility,drift ;
int i;
cout<<"Enter the current price:\n";
cin>>currentprice;
cout<<"\n";
cout<<"Enter the risk free rate:\n";
cin>>riskfreerate;
cout<<"\n";
cout<<"Enter the volatility:\n";
cin>>volatility;
cout<<"\n";
drift = riskfreerate-(pow(volatility,2)/2);
for(i=1;i<10000;i++)
{
newprice= currentprice*exp(drift+(volatility*inverse_gaussian(rand())));
cout<<i<<" "<<newprice<<endl;
}
}
error: In function 'int main()':
26:56: error: no match for 'operator*' (operand types are 'float' and 'boost::math::inverse_gaussian')
26:56: note: candidates are:
In file included from /usr/include/boost/config/no_tr1/complex.hpp:21:0,
from /usr/include/boost/math/special_functions/math_fwd.hpp:30,
from /usr/include/boost/math/special_functions/erf.hpp:13,
from /usr/include/boost/math/distributions/inverse_gaussian.hpp:53,
from 3:
/usr/include/c++/4.9/complex:381:5: note: template<class _Tp> std::complex<_Tp> std::operator*(const std::complex<_Tp>&, const std::complex<_Tp>&)
operator*(const
complex<_Tp>& __x, const complex<_Tp>& __y)
i dont know how to use inverse gaussian and how many parameters does it take. I want to enter random numbers as parameter inside it.
Aucun commentaire:
Enregistrer un commentaire