Philip H. Dybvig
Washington University
Saint Louis, Missouri
value probability
uS p
dS 1-p
This is implicit in our notation
|- uS -| |- dSwhere the up move has probability p.
value probability
uS p
dS 1-p
has the distribution function
| 0 x < dS
F(x) = -| 1-p dS <= x < uS
| 1 uS <= x
| 0 x < 0
F(x) = -| x 0 <= x < 1
| 1 1 <= x
Therefore, for 0 <= a < b <= 1, The probability that
y lies in the interval [a,b] is simply the length b-a of the
interval.
| u z < p -| | d p <= zboth (1) as a list of values and probabilities and (2) as a distribution function. Assume that d < u.
To generate a uniform variate, we take (double) rand()/(double) RAND_MAX. A variable that is U(0,1) has a mean of 1/2 and a variance of 1/12, so we can generate a uniform variate with mean m and standard deviation s as
m + s * (((double)rand()/(double)RAND_MAX)-0.5)*sqrt((double) 12).
This is implicit in our program this week.
i i i i i i
C = C r + Sum (S r - S ) - Sum d |S r - S |.
t t-1 t i t-1 t t i i t-1 t t
With taxes, things are much messier. (See my paper with Hyeng-Keun Koo.)
//
// simu1.h Asset Allocation Header
//
struct termvals {
double termstock;
double termwealth;};
class aa {
public:
aa(double ttm=1.0,int nper=120,double r=.05,double mean=.15,double stddev=.2);
int restart(double ttm,int nper,double r,double mean,double stddev);
termvals fixprops(double inrisky,double initstock=0.0,double initcash=100.0);
private:
int npers;
double tinc, r1per, mean1per, std1persqrt12, wealth, stockpos, cash, stockP, stockret;
double stocktotret();};
//
// simu1test.cc Asset Allocation test file
//
#include <iostream.h>
#include "simu1.h"
main() {
int i;
aa sim1;
termvals y;
for(i=0;i<100;i++) {
y = sim1.fixprops(.5);
cout << y.termstock << " " << y.termwealth << endl;}
return(0);}
// // simu1.cc Asset Allocation Simulation // #include <math.h> #include <stdlib.h> #include <iostream.h> #include "simu1.h" #define unifrand() ((double) rand()/((double) RAND_MAX))
aa::aa(double ttm,int nper,double r,double mean,double stddev) {
restart(ttm,nper,r,mean,stddev);}
int aa::restart(double ttm,int nper,double r,double mean,double stddev) {
npers = nper;
tinc = ttm/(double) nper;
r1per = 1.0 + r*tinc;
mean1per = 1.0 + mean*tinc;
std1persqrt12 = sqrt((double) 12)*stddev*sqrt(tinc);
// cout << " " << npers << " " << tinc << " " << r1per << " "
// << mean1per << " " << std1persqrt12 << endl;
return(0);}
termvals aa::fixprops(double inrisky,double initstock,double initcash) {
int i;
termvals x;
stockpos = initstock;
cash = initcash;
stockP = 100.0;
// cout << npers << endl;
for(i=0;i<npers;i++) {
wealth = stockpos + cash;
stockpos = inrisky * wealth;
cash = wealth - stockpos;
stockret = stocktotret();
//cout << stockret << " " << tinc << " " << mean1per << " " << std1persqrt12 <<
//" " << unifrand() <<endl;
stockP *= stockret;
stockpos *= stockret;
cash *= r1per;
// cout << stockret << " " << stockP << " " << stockpos << " " << cash << endl;
}
x.termstock = stockP;
x.termwealth = stockpos + cash;
return(x);}
double aa::stocktotret() {
return(mean1per + std1persqrt12 * (unifrand()-0.5));}