use of suite.primitive.adt.pair.FltObjPair in project suite by stupidsing.
the class TimeSeries method hurstFwf.
// http://www.financialwisdomforum.org/gummy-stuff/hurst.htm
public double hurstFwf(float[] ys, int tor) {
float[] logys = To.vector(ys, Math::log);
float[] returns0 = dropDiff_(1, logys);
int length = returns0.length;
List<FltObjPair<float[]>> pairs = new ArrayList<>();
for (int n = 0; n < length * 3 / 4; n++) {
float[] returns = Arrays.copyOfRange(returns0, n, length);
MeanVariance mv = stat.meanVariance(returns);
double mean = mv.mean;
float[] devs = To.vector(returns, r -> r - mean);
double min = Double.MAX_VALUE;
double max = Double.MIN_VALUE;
double sum = 0d;
for (float dev : devs) {
sum += dev;
min = min(sum, min);
max = max(sum, max);
}
double x = Math.log(returns.length);
double y = (max - min) / mv.standardDeviation();
pairs.add(FltObjPair.of((float) y, new float[] { (float) x, 1f }));
}
return stat.linearRegression(Read.from(pairs)).coefficients[0];
}
Aggregations