Class: FeldtRuby::Statistics::DiffusionKDE
- Defined in:
- lib/feldtruby/statistics.rb
Instance Attribute Summary collapse
-
#densities ⇒ Object
readonly
Returns the value of attribute densities.
-
#mesh ⇒ Object
readonly
Returns the value of attribute mesh.
Instance Method Summary collapse
- #density_of(value) ⇒ Object
-
#initialize(rvalue) ⇒ DiffusionKDE
constructor
Given a R object with the four sub-values named densities, mesh, sum_density, mesh_interval, min, max we can calculate the probability of new values.
- #probability_of(value) ⇒ Object
Constructor Details
#initialize(rvalue) ⇒ DiffusionKDE
Given a R object with the four sub-values named densities, mesh, sum_density, mesh_interval, min, max we can calculate the probability of new values.
198 199 200 201 202 203 204 |
# File 'lib/feldtruby/statistics.rb', line 198 def initialize(rvalue) @probabilities = rvalue.probabilities @densities = rvalue.densities @mesh = rvalue.mesh @mesh_interval = rvalue.mesh_interval.to_f @min, @max = rvalue.min.to_f, rvalue.max.to_f end |
Instance Attribute Details
#densities ⇒ Object (readonly)
Returns the value of attribute densities.
194 195 196 |
# File 'lib/feldtruby/statistics.rb', line 194 def densities @densities end |
#mesh ⇒ Object (readonly)
Returns the value of attribute mesh.
194 195 196 |
# File 'lib/feldtruby/statistics.rb', line 194 def mesh @mesh end |
Instance Method Details
#density_of(value) ⇒ Object
206 207 208 209 210 |
# File 'lib/feldtruby/statistics.rb', line 206 def density_of(value) return 0.0 if value < @min || value > @max bin_index = ((value - @min) / @mesh_interval).floor @densities[bin_index] end |
#probability_of(value) ⇒ Object
212 213 214 215 216 |
# File 'lib/feldtruby/statistics.rb', line 212 def probability_of(value) return 0.0 if value < @min || value > @max bin_index = ((value - @min) / @mesh_interval).floor @probabilities[bin_index] end |