Hi @YL0910,
The behaviour you are observing is a result of how the nengo.Node
interprets inputs given to it when it is created. With a nengo.Node
, if the input is a callable object (e.g., a Python function), the node will call that callable object during each timestep to generate the node’s output. However, if the node is presented with a non-callable object (e.g., a Python list, or scalar value), the node will output that value (unchanged) for every timestep in the simulation.
Since np.random.normal(...)
returns a scalar value when called, what Nengo is doing is evaluating the normal
function call (i.e., generating a sample) and then using the same value for every simulation timestep. You can see the result of this by printing out the values of sim.data[Probe_Gauss]
.
To get the Nengo node to function like the standalone Numpy call, you’ll need to encapsulate the np.random.normal(...)
function within a function. The easiest way to do it is to use a lambda function, like so:
with model:
Gauss = nengo.Node(lambda t: np.random.normal(loc=0.0, scale=0.707))
When you use the code above, Nengo will call the lambda function in each timestep of the simulation, which in turn calls the np.random.normal
function, generating a new value for each timestep.
I should note that Nengo also provides a WhiteNoise
process to generate Gaussian white noise signals as well. This Nengo example goes through what processes are, and how to use them. For your specific code, the equivalent Nengo node (with process) looks like this:
with model:
Gauss = nengo.Node(
nengo.processes.WhiteNoise(dist=nengo.dists.Gaussian(0, 0.707), scale=False)
)
Sort of. If you read the documentation for the nengo.Ensemble, you’ll see that the noise
parameter is:
The difference between using a node to inject noise into an ensemble, and using the noise
parameter of the ensemble is that signals injected into an ensemble via a connection will have the signal go through (get multiplied) by the ensemble’s encoders (if you are not connecting directly to the .neurons
object). If you use the noise
parameter when creating the ensemble, the noise is injected as current, bypassing the ensemble’s encoders. If you want to inject custom noise into the ensemble, you can create your own process (see the example I linked above) to read the data from file, and output them into your simulation.
Alternatively, if your noise data is not that large, you can read the data (from file) into memory, then use a Python function (with nengo.Node
) or a custom process to iterate through the data during each timestep of the simulation.
EDIT: It seems like while I was crafting my response, @Eric did post a response to some of your questions, but we both arrived at the same conclusion. 