MathPHP\Statistics\Distribution::cumulativeRelativeFrequency PHP Метод

cumulativeRelativeFrequency() публичный статический Метод

Cumulative relative frequency = cumulative frequency / sample size The values of the input array will be the keys of the result array. The cumulative frequency of the values will be the value of the result array for that key.
public static cumulativeRelativeFrequency ( array $values ) : array
$values array Ex: ( A, A, A, A, A, A, B, B, B, C )
Результат array cumulative relative frequency distribution Ex: ( A => 0.6, B => 0.9, C => 1 )
    public static function cumulativeRelativeFrequency(array $values) : array
    {
        $sample_size = count($values);
        $cumulative_frequencies = self::cumulativeFrequency($values);
        return array_map(function ($frequency) use($sample_size) {
            return $frequency / $sample_size;
        }, $cumulative_frequencies);
    }