Code Duplication    Length = 24-25 lines in 2 locations

src/Math/Stats.php 2 locations

@@ 798-821 (lines=24) @@
795
     * @see stDev()
796
     * @see calc()
797
     */
798
    public function skewness()
799
    {
800
        if (!array_key_exists('skewness', $this->_calculatedValues)) {
801
            try {
802
                $count = $this->count();
803
                try {
804
                    $stDev = $this->stDev();
805
                    try {
806
                        $sumdiff3 = $this->__sumdiff(3);
807
                    } catch (\PEAR_Exception $e) {
808
                        return $sumdiff3;
809
                    }
810
                } catch (\PEAR_Exception $e) {
811
                    return $stDev;
812
                }
813
            } catch (\PEAR_Exception $e) {
814
                return $count;
815
            }
816
817
            $this->_calculatedValues['skewness'] = ($sumdiff3 / ($count * pow($stDev, 3)));
818
        }
819
        return $this->_calculatedValues['skewness'];
820
    }
821
822
    /**
823
     * Calculates the kurtosis of the data distribution in the set
824
     * The kurtosis measures the degrees of peakedness of a distribution.
@@ 840-864 (lines=25) @@
837
     * @see stDev()
838
     * @see calc()
839
     */
840
    public function kurtosis()
841
    {
842
        if (!array_key_exists('kurtosis', $this->_calculatedValues)) {
843
            try {
844
                $count = $this->count();
845
                try {
846
                    $stDev = $this->stDev();
847
                    try {
848
                        $sumdiff4 = $this->__sumdiff(4);
849
                    } catch (\PEAR_Exception $e) {
850
                        return $sumdiff4;
851
                    }
852
                } catch (\PEAR_Exception $e) {
853
                    return $stDev;
854
                }
855
            } catch (\PEAR_Exception $e) {
856
                return $count;
857
            }
858
859
            $this->_calculatedValues['kurtosis'] = ($sumdiff4 / ($count * pow($stDev, 4))) - 3;
860
        }
861
        return $this->_calculatedValues['kurtosis'];
862
    }
863
864
    /**
865
     * Calculates the median of a data set.
866
     * The median is the value such that half of the points are below it
867
     * in a sorted data set.