Package ca.nengo.math

Examples of ca.nengo.math.Function.map()


    CurveFitter lcf = new LinearCurveFitter();
    float[][] values = new float[2][10];
   
    for (int i=0; i<values[0].length; i++) {
      values[0][i] = -9 + i * 2;
      values[1][i] = target.map(new float[]{values[0][i]});
    }
   
    Function fitted = lcf.fit(values[0], values[1]);
   
//    Plotter.plot(target, -10, 0.1f, 10, "target");
View Full Code Here


   
    float targetVal = 0f;
    float fittedVal = 0f;
    for (int i=-8; i<9; i=i+2) {
      targetVal = target.map(new float[]{i});
      fittedVal = fitted.map(new float[]{i});
      TestUtil.assertClose(targetVal, fittedVal, 15f);
    }
 
  }
 
View Full Code Here

    float[][] values = new float[polyCoeffs.length][];
    for (int i = 0; i < values.length; i++) {
      Function component = new Polynomial(polyCoeffs[i]);
      values[i] = new float[evalPoints.length];
      for (int j = 0; j < evalPoints.length; j++) {
        values[i][j] = component.map(new float[]{evalPoints[j]});
      }
    }

    LinearApproximator approximator = new IndependentDimensionApproximator(evalPoints, values, new int[]{0,1,0}, 2, new ConstantFunction(1,1f), 0f);
    float[] coefficients = approximator.findCoefficients(target);
View Full Code Here

    Function g = f.getDerivative();
    NumericallyDifferentiableFunction wrap = new NumericallyDifferentiableFunction(f, 0, 0.01f);
    Function gWrap = wrap.getDerivative();
   
    assertEquals(gWrap.getDimension(), g.getDimension());
    TestUtil.assertClose(gWrap.map(new float[]{0f}), g.map(new float[]{0f}), .0001f);
    TestUtil.assertClose(gWrap.map(new float[]{-1f}), g.map(new float[]{-1f}), .0001f);
    TestUtil.assertClose(gWrap.map(new float[]{3f}), g.map(new float[]{3f}), .0001f);
  }

}
View Full Code Here

    NumericallyDifferentiableFunction wrap = new NumericallyDifferentiableFunction(f, 0, 0.01f);
    Function gWrap = wrap.getDerivative();
   
    assertEquals(gWrap.getDimension(), g.getDimension());
    TestUtil.assertClose(gWrap.map(new float[]{0f}), g.map(new float[]{0f}), .0001f);
    TestUtil.assertClose(gWrap.map(new float[]{-1f}), g.map(new float[]{-1f}), .0001f);
    TestUtil.assertClose(gWrap.map(new float[]{3f}), g.map(new float[]{3f}), .0001f);
  }

}
View Full Code Here

    Function gWrap = wrap.getDerivative();
   
    assertEquals(gWrap.getDimension(), g.getDimension());
    TestUtil.assertClose(gWrap.map(new float[]{0f}), g.map(new float[]{0f}), .0001f);
    TestUtil.assertClose(gWrap.map(new float[]{-1f}), g.map(new float[]{-1f}), .0001f);
    TestUtil.assertClose(gWrap.map(new float[]{3f}), g.map(new float[]{3f}), .0001f);
  }

}
View Full Code Here

    PolynomialCurveFitter pcf = new PolynomialCurveFitter(3);
    float[][] values = new float[2][10];

    for (int i=0; i<values[0].length; i++) {
      values[0][i] = -9 + i * 2;
      values[1][i] = target.map(new float[]{values[0][i]});
    }

    Function fitted = pcf.fit(values[0], values[1]);

//    Plotter.plot(target, -10, 0.05f, 10, "target");
View Full Code Here

    float targetVal = 0f;
    float fittedVal = 0f;
    for (int i=-8; i<9; i=i+2) {
      targetVal = target.map(new float[]{i});
      fittedVal = fitted.map(new float[]{i});
      TestUtil.assertClose(targetVal, fittedVal, 10f);
    }

    pcf = new PolynomialCurveFitter(2);
View Full Code Here

    float[] x = new float[50];
    float[] y = new float[50];
    float dx = 0.1f;
    for (int i = 0; i < x.length; i++) {
      x[i] = i*dx;
      y[i] = fitted.map(new float[]{x[i]});
    }

//    TimeSeries1D approx = new TimeSeries1DImpl(x, y, Units.UNK);
//    TimeSeries1D actual = new TimeSeries1DImpl(examplex, exampley, Units.UNK);

View Full Code Here

//    TimeSeries1D approx = new TimeSeries1DImpl(x, y, Units.UNK);
//    TimeSeries1D actual = new TimeSeries1DImpl(examplex, exampley, Units.UNK);

    for (int i = 0; i < examplex.length; i++) {
      TestUtil.assertClose(exampley[i], fitted.map(new float[]{examplex[i]}), 0.5f);
    }

  }

    public static void main(String[] args) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.