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).
Distributions are assumed to be complete populations, i.e. this class is unsuitable for samples.
It is notable that common dice create symmetric distributions, which means that skewness is 0, while measures of central tendency (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.
34 35 36 37 38 |
# File 'lib/dicey/distribution_properties_calculator.rb', line 34 def call(distribution) return {} if distribution.empty? calculate_properties(distribution) end |