Class: Atmospheris::Iso5878::RiceDistribution
- Inherits:
-
Object
- Object
- Atmospheris::Iso5878::RiceDistribution
- Defined in:
- lib/atmospheris/iso5878/rice_distribution.rb
Overview
Encapsulates a single Rice (circular normal) distribution instance with fixed parameters (Vr, sigma_r).
Wraps the existing module-level methods (bessel_i0, rice_pdf, etc.) in an object-oriented interface, enabling lazy caching and clean composition by WindObservation.
Instance Attribute Summary collapse
-
#sigma ⇒ Object
readonly
Returns the value of attribute sigma.
-
#sigma_r ⇒ Object
readonly
Returns the value of attribute sigma_r.
-
#vr ⇒ Object
readonly
Returns the value of attribute vr.
Instance Method Summary collapse
-
#cdf(x) ⇒ Float
Cumulative distribution function at wind speed x.
-
#initialize(vr:, sigma_r:) ⇒ RiceDistribution
constructor
A new instance of RiceDistribution.
-
#mean ⇒ Float
Analytical mean of the Rice distribution (Eq. 4).
-
#pdf(nu) ⇒ Float
Probability density at wind speed nu.
-
#percentile_bounds ⇒ Hash{Integer => PercentilePair}
Percentile bounds as defined in ISO 5878.
-
#quantile(p) ⇒ Float
Inverse CDF (quantile function) for probability p.
Constructor Details
#initialize(vr:, sigma_r:) ⇒ RiceDistribution
Returns a new instance of RiceDistribution.
22 23 24 25 26 |
# File 'lib/atmospheris/iso5878/rice_distribution.rb', line 22 def initialize(vr:, sigma_r:) @vr = vr.to_f @sigma_r = sigma_r.to_f @sigma = @sigma_r / Math.sqrt(2) end |
Instance Attribute Details
#sigma ⇒ Object (readonly)
Returns the value of attribute sigma.
18 19 20 |
# File 'lib/atmospheris/iso5878/rice_distribution.rb', line 18 def sigma @sigma end |
#sigma_r ⇒ Object (readonly)
Returns the value of attribute sigma_r.
18 19 20 |
# File 'lib/atmospheris/iso5878/rice_distribution.rb', line 18 def sigma_r @sigma_r end |
#vr ⇒ Object (readonly)
Returns the value of attribute vr.
18 19 20 |
# File 'lib/atmospheris/iso5878/rice_distribution.rb', line 18 def vr @vr end |
Instance Method Details
#cdf(x) ⇒ Float
Cumulative distribution function at wind speed x.
38 39 40 |
# File 'lib/atmospheris/iso5878/rice_distribution.rb', line 38 def cdf(x) Iso5878.rice_cdf(x, vr, sigma_r) end |
#mean ⇒ Float
Analytical mean of the Rice distribution (Eq. 4). This is the calculated scalar mean wind speed Vsc.
52 53 54 |
# File 'lib/atmospheris/iso5878/rice_distribution.rb', line 52 def mean @mean ||= Iso5878.rice_mean(vr, sigma_r) end |
#pdf(nu) ⇒ Float
Probability density at wind speed nu.
31 32 33 |
# File 'lib/atmospheris/iso5878/rice_distribution.rb', line 31 def pdf(nu) Iso5878.rice_pdf(nu, vr, sigma_r) end |
#percentile_bounds ⇒ Hash{Integer => PercentilePair}
Percentile bounds as defined in ISO 5878. Returns hash mapping percentage to PercentilePair (low/high).
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/atmospheris/iso5878/rice_distribution.rb', line 59 def percentile_bounds @percentile_bounds ||= { 1 => PercentilePair.new( low: quantile(0.01), high: quantile(0.99) ), 10 => PercentilePair.new( low: quantile(0.10), high: quantile(0.90) ), 20 => PercentilePair.new( low: quantile(0.20), high: quantile(0.80) ) } end |
#quantile(p) ⇒ Float
Inverse CDF (quantile function) for probability p.
45 46 47 |
# File 'lib/atmospheris/iso5878/rice_distribution.rb', line 45 def quantile(p) Iso5878.rice_inv_cdf(p, vr, sigma_r) end |