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.
376 377 378 379 |
# File 'lib/neuronet.rb', line 376 def initialize(factor=1.0,center=nil,spread=nil) super(factor, center, spread) self.init = false end |
Instance Method Details
#set_center(inputs) ⇒ Object
381 382 383 |
# File 'lib/neuronet.rb', line 381 def set_center(inputs) self.center = inputs.inject(0.0,:+) / inputs.length end |
#set_spread(inputs) ⇒ Object
385 386 387 388 389 |
# File 'lib/neuronet.rb', line 385 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 |