Empirical Distribution (ECDF) - estebanz01/ruby-statistics GitHub Wiki
Empirical Distribution
This distribution is an implementation of the empirical distribution used by the Kolmogorov-Smirnov Test, which compares two sets of distributions to determine if both are the same or not. More details, here: https://en.wikipedia.org/wiki/Empirical_distribution_function.
Instance methods
Initialize
In order to initialize this distribution, you need to pass the samples using the samples:
keyword. An object that responds to Enumerable methods is expected.
1] pry(main)> Distribution::Empirical
=> Statistics::Distribution::Empirical
[2] pry(main)> Distribution::Empirical.new(samples: [1, 2, 3, 4, 5, 6, 7])
=> #<Statistics::Distribution::Empirical:0x00007f4167bb6700 @samples=[1, 2, 3, 4, 5, 6, 7]>
Cumulative function
This function calculates the probablity P(x <= X)
for the specified keyword value x:
.
[3] pry(main)> empirical = Distribution::Empirical.new(samples: [1, 2, 3, 4, 5, 6, 7])
=> #<Statistics::Distribution::Empirical:0x00007f4166fc2750 @samples=[1, 2, 3, 4, 5, 6, 7]>
[4] pry(main)> empirical.cumulative_function(x: 3)
=> 0.42857142857142855