Ralph Vince - Portfolio Mathematics

(Brent) #1

The Leverage Space Portfolio Model in the Real World 395


while(1==1){
long passed=0;
long nopermutations = (long)
Math.pow((double)hpr.length,(double)counter);
for(long pn=0;pn<nopermutations;pn++){
double hprpermutation[]=nPqi(counter,pn);

passed+=(long)B(hprpermutation,usedrawdowninsteadofruin);
}
double result=1.0-
(double)passed/(double)nopermutations;
System.out.println(counter+” = ”+result);
counter++;
}
}
}


The code is presented “as-is,” with no warranties whatsoever. Use it as
you see fit. It is merely a bare-bones implementation of Equation (12.05).
I wrote it in as generic a flavor of Java as possible, intentionally avoided
using an object-oriented approach, and intentionally kept it in the lowest-
common-denominator syntax across languages, so that you can transport
it to other languages more easily. The code can be madefarmore efficient
than what is presented here. This is presented merely to give programmers
of this concept a starting reference point.
Note that the input file format must be formatted as follows: a straight
ASCII text file, wherein the first line is the scenario spectrum name, the
second line is the fvalue to be used on that scenario spectrum, and all
subsequent lines are the simple stream of individual scenario outcomes.
For example:


Coin Toss 1
.25
− 1
2

This shows the scenario spectrum “Coin Toss 1,” at anfof .25 with two
outcomes, one of –1 and the other of+2.
For situations of multiple scenario spectrums, again the first line is
the scenario spectrum names, comma-delimited is the second line; the re-
spectivefvalues, comma delimited; and each line after that represents a

Free download pdf