use of org.ojalgo.random.SampleSet in project ojAlgo-finance by optimatika.
the class FinanceUtils method estimateExcessDiffusionProcess.
public static GeometricBrownianMotion estimateExcessDiffusionProcess(final CalendarDateSeries<?> priceSeries, final CalendarDateSeries<?> riskFreeInterestRateSeries, final CalendarDateUnit timeUnit) {
final SampleSet tmpSampleSet = FinanceUtils.makeExcessGrowthRateSampleSet(priceSeries, riskFreeInterestRateSeries);
// The average number of millis between to subsequent keys in the series.
double tmpStepSize = priceSeries.getResolution().size();
// The time between to keys expressed in terms of the specified time meassure and unit.
tmpStepSize /= timeUnit.size();
final double tmpExp = tmpSampleSet.getMean();
final double tmpVar = tmpSampleSet.getVariance();
final double tmpDiff = PrimitiveFunction.SQRT.invoke(tmpVar / tmpStepSize);
final double tmpDrift = (tmpExp / tmpStepSize) + ((tmpDiff * tmpDiff) / TWO);
final GeometricBrownianMotion retVal = new GeometricBrownianMotion(tmpDrift, tmpDiff);
return retVal;
}
Aggregations