Package ca.nengo.util

Examples of ca.nengo.util.TimeSeries


public class RK45IntegratorTest extends TestCase {

  public void testIntegrate() {
    VanderPol system = new VanderPol(new float[]{.1f, .1f});
    Integrator integrator = new RK45Integrator();
    TimeSeries input = new TimeSeriesImpl(new float[]{0, 10f}, new float[][]{new float[0], new float[0]}, new Units[]{});
    TimeSeries result = integrator.integrate(system, input);
   
    assertTrue(result.getTimes().length < 60);
   
    //check results against selected hard-coded values from matlab solution ...
    InterpolatorND interpolator = new LinearInterpolatorND(result);
    float tolerance = 0.005f;
    float[] time2 = interpolator.interpolate(2);
View Full Code Here


   * SpikeGenerator.
   *
   * @see ca.nengo.model.Probeable#getHistory(java.lang.String)
   */
  public TimeSeries getHistory(String stateName) throws SimulationException {
    TimeSeries result = null;
    if (stateName.equals("I")) {
      result = myCurrent;
    } else if (stateName.equals("rate")) {
      InstantaneousOutput output = mySpikeOrigin.getValues();
      float[] times = myCurrent.getTimes();
View Full Code Here

    network.addProjection(input.getOrigin(FunctionInput.ORIGIN_NAME), pre.getTermination("input"));
    Projection projection = network.addProjection(pre.getOrigin(NEFEnsemble.X), post.getTermination("pre"));
   
    Probe pPost = network.getSimulator().addProbe("post", NEFEnsemble.X, true);
    network.run(0, 2);
    TimeSeries ideal = pPost.getData();
    Plotter.plot(pPost.getData(), .005f, "mixed weights result");   
   
    //remove negative weights ...
    System.out.println("Minimum weight without bias: " + MU.min(projection.getWeights()));
    projection.addBias(100, .005f, tauPSC, true, false);
    System.out.println("Minimum weight with bias: " + MU.min(projection.getWeights()));
    pPost.reset();
    network.run(0, 2);
    TimeSeries diff = new TimeSeriesImpl(ideal.getTimes(), MU.difference(ideal.getValues(), pPost.getData().getValues()), ideal.getUnits());
    Plotter.plot(diff, .01f, "positive weights");
   
    projection.removeBias();
    projection.addBias(100, tauPSC/5f, tauPSC, true, true);
    pPost.reset();
View Full Code Here

    for (int i = 0; i < steps; i++) {
      generator.run(new float[]{i*dt, (i+1)*dt}, new float[]{current, current});
    }

    TimeSeries history = generator.getHistory("rate");
    return history.getValues()[0][0];
  }
View Full Code Here

    float[] current = new float[]{0f, .25f, .5f, .75f, 1f, 1.25f, 1.5f, 1.75f, 2f, 2.25f, 2.5f, 2.75f, 3f, 3.5f, 4f, 5f, 6f, 8f, 10f, 15f, 20f, 30f, 40f, 50f, 60f};
    float[] Vm = new float[current.length];
    float[] rt = new float[current.length];
    for (int i = 0; i < current.length; i++) {
      TimeSeries input = new TimeSeriesImpl(new float[]{0, 0.5f},
          new float[][]{new float[]{current[i], 1.0f}, new float[]{current[i], 1.0f}}, new Units[]{Units.uAcm2, Units.UNK});
      TimeSeries output = myIntegrator.integrate(myDynamics, input);
      Vm[i] = output.getValues()[output.getValues().length - 1][0];
      reset(false);
//      Plotter.plot(output, "simulation "+i);
      rt[i] = getRefreactoryTime(Vm[i]);
    }
View Full Code Here

      float[][] input = new float[current.length][];
      for (int i = 0; i < input.length; i++) {
        input[i] = new float[]{current[i], myDopamine};
      }

      TimeSeries output = myIntegrator.integrate(myDynamics,
          new TimeSeriesImpl(time, input, new Units[]{Units.uAcm2, Units.UNK}));

      myMembranePotentialHistory = output;

      if (myMode.equals(SimulationMode.RATE)) {
        float Vm = output.getValues()[0][0];
        float rate = (Vm > Vf) ? 1f / getRefreactoryTime(Vm) : 0;
        result = new RealOutputImpl(new float[]{rate}, Units.SPIKES_PER_S, time[time.length-1]);
      } else {
        boolean spike = false;
        for (int i = 0; i < output.getTimes().length && !spike; i++) { //note: this only allows 1 spike / step
          float Vm = output.getValues()[i][0];
          if (Vm > Vf) {
            float refractoryTime = getRefreactoryTime(Vm);
            if (output.getTimes()[i] - myLastSpikeTime >= refractoryTime) {
              spike = true;
              myLastSpikeTime = output.getTimes()[i];
            }
          }
        }
        result = new SpikeOutputImpl(new boolean[]{spike}, Units.SPIKES, time[time.length-1]);
      }
View Full Code Here

      times = new float[]{firstNodeTimes[firstNodeTimes.length - 1]};

      values = new float[][]{new float[myNodes.length]};
      for (int i = 0; i < myNodes.length; i++) {
        if (nodeNumbers.contains(Integer.valueOf(i))) {
          TimeSeries history = ((Probeable) myNodes[i]).getHistory(stateName);
          int index = history.getTimes().length - 1;
          values[0][i] = history.getValues()[index][0];
          if (i == 0) {
                        units[i] = history.getUnits()[0];
                    }
        }
      }
    }
View Full Code Here

                    return;
                }

            }

            TimeSeries timeSeriesToShow = timeSeries;

            if (subSampling != 0) {
                timeSeriesToShow = DataUtils.subsample(timeSeriesToShow, subSampling);
            }
View Full Code Here

   * Test method for {@link ca.nengo.math.impl.TimeSeriesFunction#map(float[])}.
   * @throws StructuralException
   */
  public void testMap() throws StructuralException {
    //this is code that was giving Lloyd some trouble (not really a unit test) ...
    TimeSeries ts = new TimeSeries1DImpl(new float[]{ 0.0f, 0.5f, 1.0f},
        new float[]{0.0f, 0.5f, 1.0f}, Units.UNK);
    Function f = new TimeSeriesFunction(ts , 0);
//    FunctionInput input = new FunctionInput("input", new Function[]{f}, Units.UNK);

    //now for a little test
View Full Code Here

  }

    //functional test
    public static void main(String[] args) {
        Function f = new SineFunction(10);
        TimeSeries series = TimeSeriesFunction.makeSeries(f, 0, .001f, 1, Units.UNK);
        Plotter.plot(f, 0, .001f, 1, "function output");
        Plotter.plot(series, "time series");

        Function f2 = new TimeSeriesFunction(series, 0);
        Plotter.plot(f2, 0, .0005f, 1, "derived function");
View Full Code Here

TOP

Related Classes of ca.nengo.util.TimeSeries

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.