Class: Dicey::DistributionPropertiesCalculator
- Inherits:
-
Object
- Object
- Dicey::DistributionPropertiesCalculator
- Includes:
- Mixins::RationalToInteger
- Defined in:
- lib/dicey/distribution_properties_calculator.rb
Overview
Calculates distribution properties, also known as descriptive statistics when applied to a population sample.
These are well-known properties such as:
-
min, max, mid-range;
-
mode(s), median, arithmetic mean;
-
important moments (expected value, variance, skewness, kurtosis).
It is notable that most dice create symmetric distributions, which means that skewness is 0, while properties denoting center in some way (median, mean, …) are all equal. Mode is often not unique, but includes this center.
Instance Method Summary collapse
-
#call(distribution) ⇒ Hash{Symbol => Any}
Calculate properties for a given distribution.
Instance Method Details
#call(distribution) ⇒ Hash{Symbol => Any}
Calculate properties for a given distribution.
Depending on values in the distribution, some properties may be undefined. In such cases, only mode(s) are guaranteed to be present.
On empty distribution, returns an empty hash.
31 32 33 34 35 |
# File 'lib/dicey/distribution_properties_calculator.rb', line 31 def call(distribution) return {} if distribution.empty? calculate_properties(distribution) end |