Search in sources :

Example 6 with SampleSet

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;
}
Also used : SampleSet(org.ojalgo.random.SampleSet) GeometricBrownianMotion(org.ojalgo.random.process.GeometricBrownianMotion)

Aggregations

SampleSet (org.ojalgo.random.SampleSet)6 Test (org.junit.jupiter.api.Test)2 PrimitiveMatrix (org.ojalgo.matrix.PrimitiveMatrix)2 LogNormal (org.ojalgo.random.LogNormal)2 GeometricBrownianMotion (org.ojalgo.random.process.GeometricBrownianMotion)2 PrimitiveSeries (org.ojalgo.series.primitive.PrimitiveSeries)2 ArrayList (java.util.ArrayList)1 Tag (org.junit.jupiter.api.Tag)1 Primitive64Array (org.ojalgo.array.Primitive64Array)1 Normal (org.ojalgo.random.Normal)1 CalendarDateSeries (org.ojalgo.series.CalendarDateSeries)1 CoordinationSet (org.ojalgo.series.CoordinationSet)1 CalendarDateUnit (org.ojalgo.type.CalendarDateUnit)1