/// <summary> /// Computes the neuron /// </summary> /// <param name="stimuli">Input stimulation</param> /// <param name="collectStatistics">Specifies whether to update internal statistics</param> public void Compute(double stimuli, bool collectStatistics) { stimuli = stimuli.Bound(); if (collectStatistics) { StimuliStat.AddSampleValue(stimuli); } _signalConverter.EncodeAnalogValue(stimuli); return; }
/// <summary> /// Function mixes three analog values in the specified range into the one. /// Order of values: the first is the most important. /// </summary> /// <param name="analogRange">Range of analog values</param> /// <param name="a1">Analog value 1</param> /// <param name="a2">Analog value 2</param> /// <param name="a3">Analog value 3</param> /// <param name="s1">Spikes (bits) for analog value 1</param> /// <param name="s2">Spikes (bits) for analog value 2</param> /// <param name="s3">Spikes (bits) for analog value 3</param> /// <returns></returns> public static double Mix(Interval analogRange, double a1, double a2, double a3, int s1, int s2, int s3 ) { //Check spikes if (s1 + s2 + s3 > MaxCodingFractions) { throw new Exception("s1 + s2 +s3 > MaxCodingSpikes"); } SignalConverter sc1 = new SignalConverter(analogRange, s1); SignalConverter sc2 = new SignalConverter(analogRange, s2); SignalConverter sc3 = new SignalConverter(analogRange, s3); SignalConverter scm = new SignalConverter(analogRange, s1 + s2 + s3); sc1.EncodeAnalogValue(a1); sc2.EncodeAnalogValue(a2); sc3.EncodeAnalogValue(a3); ulong buffer = 0; for (int i = 0; i < s1; i++) { buffer <<= 1; ulong bit = (ulong)sc1.FetchSpike(); buffer |= bit; } for (int i = 0; i < s2; i++) { buffer <<= 1; ulong bit = (ulong)sc2.FetchSpike(); buffer |= bit; } for (int i = 0; i < s3; i++) { buffer <<= 1; ulong bit = (ulong)sc3.FetchSpike(); buffer |= bit; } scm.EncodeSpikeTrain(buffer); return(scm.FetchAnalogValue()); }