public function computeStatistics( array $pTimeSeries ) {
        $statistics = array('min'       => 0,
                            'max'       => 0,
                            'stdDev'    => 0,
                            'mean'      => 0,
                            'sum'       => 0,
                            'size'      => count( $pTimeSeries ) );

        foreach ( $pTimeSeries as $entry ) {
            if ( $entry['count'] < $statistics['min'] ) {
                $statistics['min'] = $entry['count'];
            }
            if ( $entry['count'] > $statistics['max'] ) {
                $statistics['max'] = $entry['count'];
            }

            $statistics['sum'] += $entry['count'];
        }

        $statistics['mean'] = $statistics['sum'] / $statistics['size'];

        // standard deviation
        foreach ($pTimeSeries as $entry) {
            $statistics['stdDev'] += pow( $entry['count'] - $statistics['mean'], 2 );
        }
        if ( $statistics['size'] > 1 ) {
            $statistics['stdDev'] = sqrt( $statistics['stdDev'] / ( $statistics['size'] - 1 ) );
        } else {
            // standard deviation of a single element is 0
            $statistics['stdDev'] = 0;
        }
        
        return $statistics;   
    }
public function computeStatistics( array $pTimeSeries ) {
        $statistics = array('min'       => 0,
                            'max'       => 0,
                            'stdDev'    => 0,
                            'mean'      => 0,
                            'sum'       => 0,
                            'size'      => count( $pTimeSeries ) );

        foreach ( $pTimeSeries as $entry ) {
            if ( $entry['count'] < $statistics['min'] ) {
                $statistics['min'] = $entry['count'];
            }
            if ( $entry['count'] > $statistics['max'] ) {
                $statistics['max'] = $entry['count'];
            }

            $statistics['sum'] += $entry['count'];
        }

        $statistics['mean'] = $statistics['sum'] / $statistics['size'];

        // standard deviation
        foreach ($pTimeSeries as $entry) {
            $statistics['stdDev'] += pow( $entry['count'] - $statistics['mean'], 2 );
        }
        if ( $statistics['size'] > 1 ) {
            $statistics['stdDev'] = sqrt( $statistics['stdDev'] / ( $statistics['size'] - 1 ) );
        } else {
            // standard deviation of a single element is 0
            $statistics['stdDev'] = 0;
        }
        
        return $statistics;   
    }
public function computeStatistics ( array $ pTimeSeries ) { $ statistics = array ( 'min' => 0 , 'max' => 0 , 'stdDev' => 0 , 'mean' => 0 , 'sum' => 0 , 'size' => count ( $ pTimeSeries ) ) ; foreach ( $ pTimeSeries as $ entry ) { if ( $ entry [ 'count' ] < $ statistics [ 'min' ] ) { $ statistics [ 'min' ] = $ entry [ 'count' ] ; } if ( $ entry [ 'count' ] > $ statistics [ 'max' ] ) { $ statistics [ 'max' ] = $ entry [ 'count' ] ; } $ statistics [ 'sum' ] += $ entry [ 'count' ] ; } $ statistics [ 'mean' ] = $ statistics [ 'sum' ] / $ statistics [ 'size' ] ; // standard deviation foreach ( $ pTimeSeries as $ entry ) { $ statistics [ 'stdDev' ] += pow ( $ entry [ 'count' ] - $ statistics [ 'mean' ] , 2 ) ; } if ( $ statistics [ 'size' ] > 1 ) { $ statistics [ 'stdDev' ] = sqrt ( $ statistics [ 'stdDev' ] / ( $ statistics [ 'size' ] - 1 ) ) ; } else { // standard deviation of a single element is 0 $ statistics [ 'stdDev' ] = 0 ; } return $ statistics ; }
Calculates the minimum, maximum, standard deviation, mean, sum and the size
of the given time series. It must contain the key 'count' for each entry.

@param  array  $pTimeSeries Time series to calculate the described attributes
@return array               An array containing the attributes described above
Calculates the minimum maximum standard deviation mean sum and the size of the given time series . It must contain the key count for each entry .