Package ca.nengo.math

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


        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] = f.map(new float[]{x[i]});
        }

        TimeSeries1D approx = new TimeSeries1DImpl(x, y, Units.UNK);
        TimeSeries1D actual = new TimeSeries1DImpl(examplex, exampley, Units.UNK);
        Plotter.plot(approx, actual, "polynomial");
View Full Code Here


  public void testMap() throws StructuralException {
    Function f = new PDFFunction(new IndicatorPDF(0,10));
   
    int[] counts = new int[10];
    for(int i=0; i < 10000; i++)
      counts[(int)f.map(new float[]{0f})]++;
    for(int i=0; i < 10; i++)
      TestUtil.assertClose(1000, counts[i], 100);
  }
}
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

    sig[0][0] = 0;
    sig[1][0] = 1;
    sig[2][0] = 2;
    Function f = new FixedSignalFunction(sig , 0);

    TestUtil.assertClose(0f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(1f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(2f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(0f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(1f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(2f, f.map(new float[]{0f}), .00001f);
View Full Code Here

    sig[1][0] = 1;
    sig[2][0] = 2;
    Function f = new FixedSignalFunction(sig , 0);

    TestUtil.assertClose(0f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(1f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(2f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(0f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(1f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(2f, f.map(new float[]{0f}), .00001f);
  }
View Full Code Here

    sig[2][0] = 2;
    Function f = new FixedSignalFunction(sig , 0);

    TestUtil.assertClose(0f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(1f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(2f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(0f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(1f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(2f, f.map(new float[]{0f}), .00001f);
  }
}
View Full Code Here

    Function f = new FixedSignalFunction(sig , 0);

    TestUtil.assertClose(0f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(1f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(2f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(0f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(1f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(2f, f.map(new float[]{0f}), .00001f);
  }
}
View Full Code Here

    TestUtil.assertClose(0f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(1f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(2f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(0f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(1f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(2f, f.map(new float[]{0f}), .00001f);
  }
}
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.