Package ca.nengo.math.impl

Source Code of ca.nengo.math.impl.PDFFunctionTest

/**
*
*/
package ca.nengo.math.impl;

import junit.framework.TestCase;
import ca.nengo.TestUtil;
import ca.nengo.math.Function;
import ca.nengo.model.StructuralException;

/**
* Unit tests for TimeSeriesFunction.
*
* @author Daniel Rasmussen
*/
public class PDFFunctionTest extends TestCase {

  /**
   * @param arg0
   */
  public PDFFunctionTest(String arg0) {
    super(arg0);
  }

  /**
   * @see junit.framework.TestCase#setUp()
   */
  protected void setUp() throws Exception {
    super.setUp();
  }

  /**
   * Test method for {@link ca.nengo.math.impl.PDFFunction#map(float[])}.
   * @throws StructuralException
   */
  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);
  }
}
TOP

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

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.