Exemple #1
0
from ca.nengo.util import MU
from java.io import File
import math

nInput = range(200, 2001, 400)
nDiff = 1000;

networks = [interneuron, dualTC, adapting, depressing, butterworth, interneuronFeedback]

exporter = MatlabExporter()
for network in networks:
	network.setInputFunction(ConstantFunction(1, 0));
	network.setStepSize(.0001)
	network.setMode(SimulationMode.DIRECT);

	inputVariance = [];
	outputVariance = [];
	
	for n in nInput:
		network.setNoise(n, nDiff);
		#network.setDistortion(n, nDiff);
		network.reset(0)
		network.run(0, 10);
		inputVariance.append(MU.variance(MU.prod(network.getInputEnsembleData().getValues(), [1]), 0))
		outputVariance.append(MU.variance(MU.prod(network.getOutputData().getValues(), [1]), 0))
		
	network.clearErrors();
	Plotter.plot(nInput, outputVariance, "output")
	
exporter.write(File("noise.mat"));		
	
componentRMS = math.sqrt(1.0 / len(frequencies)); 
signal = FourierFunction(frequencies, MU.uniform(1, len(frequencies), componentRMS/.707)[0], MU.random(1, len(frequencies), IndicatorPDF(-.5, .5))[0])

noiseBandwidth = 500

for network in networks:
	network.setMode(SimulationMode.DIRECT);
	network.setStepSize(.0005);	
	signalPower = []
	noisePower = []
	
	for t in tau:
		network.setTau(t)
		
		network.setInputFunction(signal);
		network.clearErrors();
		network.reset(0)
		network.run(0, 10)
		signalPower.append(MU.variance(MU.prod(network.getOutputData().getValues(), [1]), 0))
		
		network.setInputFunction(ConstantFunction(1, 0));
		network.setNoise(1000, 1000);
		network.reset(0)
		network.run(0, 10);
		network.clearErrors();
		noisePower.append(MU.variance(MU.prod(network.getOutputData().getValues(), [1]), 0))

	Plotter.plot(tau, signalPower, "%s signal power" %network.getName());
	Plotter.plot(tau, noisePower, "%s noise power" %network.getName());
	network.setStepSize(.001);