Class: Neuronet::Gaussian
Overview
“Normal Distribution” Gaussian subclasses Scale and is used exactly the same way. The only changes are that it calculates the arithmetic mean (average) for center and the standard deviation for spread.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Scale
Instance Method Summary collapse
-
#initialize(factor = 1.0, center = nil, spread = nil) ⇒ Gaussian
constructor
A new instance of Gaussian.
- #set_center(inputs) ⇒ Object
- #set_spread(inputs) ⇒ Object
Methods inherited from Scale
#mapped, #set, #set_init, #unmapped
Constructor Details
#initialize(factor = 1.0, center = nil, spread = nil) ⇒ Gaussian
Returns a new instance of Gaussian.
379 380 381 382 |
# File 'lib/neuronet.rb', line 379 def initialize(factor=1.0,center=nil,spread=nil) super(factor, center, spread) self.init = false end |
Instance Method Details
#set_center(inputs) ⇒ Object
384 385 386 |
# File 'lib/neuronet.rb', line 384 def set_center(inputs) self.center = inputs.inject(0.0,:+) / inputs.length end |
#set_spread(inputs) ⇒ Object
388 389 390 391 392 |
# File 'lib/neuronet.rb', line 388 def set_spread(inputs) self.spread = Math.sqrt(inputs.map{|value| self.center - value}.inject(0.0){|sum,value| value*value + sum} / (inputs.length - 1.0)) end |