Exemplo n.º 1
0
    def test_rms(self):
        t = np.linspace(0, 1, 1000)

        for rms_desired in [0, 0.5, 1, 100]:
            f = white_noise(1, 100, rms=rms_desired)
            rms = np.sqrt(np.mean([f(tt)**2 for tt in t]))
            self.assertTrue(np.allclose(rms, rms_desired, atol=.1, rtol=.01))
Exemplo n.º 2
0
    def test_array(self):
        rms_desired = 0.5
        f = white_noise(1, 5, rms=rms_desired, dimensions=5)

        t = np.linspace(0, 1, 1000)
        data = np.array([f(tt) for tt in t])
        rms = np.sqrt(np.mean(data**2, axis=0))

        self.assertTrue(np.allclose(rms, rms_desired, atol=.1, rtol=.01))
import numpy as np
import matplotlib.pyplot as plt

import nengo
from nengo.helpers import white_noise

from base import sorted_spikes

model = nengo.Model("Communication Channel")

in_ = nengo.Node(output=white_noise(1, 5, seed=60))

a = nengo.Ensemble(nengo.LIF(30), 1, label="A")
b = nengo.Ensemble(nengo.LIF(30), 1, label="B")

nengo.Connection(in_, a)
nengo.DecodedConnection(a, b)

in_p = nengo.Probe(in_, 'output')
a_val = nengo.Probe(a, 'decoded_output', filter=0.01)
a_spikes = nengo.Probe(a, 'spikes')
b_val = nengo.Probe(b, 'decoded_output', filter=0.01)
b_spikes = nengo.Probe(b, 'spikes')

sim = nengo.Simulator(model)
sim.run(1)

t = sim.data(model.t_probe)
sim_a = next(ens for ens in sim.model.objs if ens.label == "A")
a_spikes = sorted_spikes(t, sim_a, sim.data(a_spikes))
sim_b = next(ens for ens in sim.model.objs if ens.label == "B")
Exemplo n.º 4
0
import numpy as np
import matplotlib.pyplot as plt

import nengo
from nengo.helpers import white_noise

from base import sorted_spikes

model = nengo.Model("Communication Channel")

in_ = nengo.Node(output=white_noise(1, 5, seed=60))

a = nengo.Ensemble(nengo.LIF(30), 1, label="A")
b = nengo.Ensemble(nengo.LIF(30), 1, label="B")

nengo.Connection(in_, a)
nengo.DecodedConnection(a, b)

in_p = nengo.Probe(in_, 'output')
a_val = nengo.Probe(a, 'decoded_output', filter=0.01)
a_spikes = nengo.Probe(a, 'spikes')
b_val = nengo.Probe(b, 'decoded_output', filter=0.01)
b_spikes = nengo.Probe(b, 'spikes')

sim = nengo.Simulator(model)
sim.run(1)

t = sim.data(model.t_probe)
sim_a = next(ens for ens in sim.model.objs if ens.label == "A")
a_spikes = sorted_spikes(t, sim_a, sim.data(a_spikes))
sim_b = next(ens for ens in sim.model.objs if ens.label == "B")