Package ca.nengo.math.impl

Examples of ca.nengo.math.impl.PoissonPDF


    doTestMap(30, 0, 9.35762296884019E-14f);
  }
 
  private static void doTestMap(float rate, float observation, float probability) {
    float tolerance = .00001f;
    PoissonPDF pdf = new PoissonPDF(rate);
    float result = pdf.map(new float[]{observation});
    TestUtil.assertClose(probability, result, tolerance);
  }
View Full Code Here


    doTestSample(50);
    doTestSample(100);
  }
 
  private static void doTestSample(float rate) {
    PoissonPDF pdf = new PoissonPDF(rate);
    int n = 1000;
    int[] bins = new int[100];
    for (int i = 0; i < n; i++) {
      int sample = (int) Math.round(pdf.sample()[0]);
      if (sample < bins.length) bins[sample]++;
    }
    for (int i = 0; i < bins.length; i++) {
      TestUtil.assertClose(pdf.map(new float[]{i}), (float) bins[i]/ (float) n, .05f);
    }
   
  }
View Full Code Here

      result = new RealOutputImpl(new float[]{myRateFunction.map(new float[]{current[0]})}, Units.SPIKES_PER_S, time[time.length-1]);
    } else if (myMode.equals(SimulationMode.RATE)) {
      float totalTimeSpan = time[time.length-1] - time[0];
      float ratePerSecond = myRateFunction.map(new float[]{MU.mean(current)});
      float ratePerStep = totalTimeSpan * ratePerSecond;
      float numSpikes = new PoissonPDF(ratePerStep).sample()[0];

      result = new RealOutputImpl(new float[]{numSpikes / totalTimeSpan}, Units.SPIKES_PER_S, time[time.length-1]);
    } else {
      boolean spike = false;
      for (int i = 0; i < time.length - 1 && !spike; i++) {
View Full Code Here

TOP

Related Classes of ca.nengo.math.impl.PoissonPDF

Copyright © 2018 www.massapicom. 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.