src/Webtrees/Module/Sosa/Model/SosaProvider.php
public function getMeanGenerationTime(){
        if(!$this->is_setup) return;
        if(!$this->statistics_tab){
            $this->getStatisticsByGeneration();
        }
        //Linear regression on x=generation and y=birthdate
        $sum_xy = 0;
        $sum_x=0;
        $sum_y=0;
        $sum_x2=0;
        $n=count($this->statistics_tab);
        foreach($this->statistics_tab as $gen=>$stats){
            $sum_xy+=$gen*$stats['avgBirth'];
            $sum_x+=$gen;
            $sum_y+=$stats['avgBirth'];
            $sum_x2+=$gen*$gen;
        }
        $denom=($n*$sum_x2)-($sum_x*$sum_x);
        if($denom!=0){
            return -(($n*$sum_xy)-($sum_x*$sum_y))/($denom);
        }
        return null;
    }
public function getMeanGenerationTime(){
        if(!$this->is_setup) return;
        if(!$this->statistics_tab){
            $this->getStatisticsByGeneration();
        }
        //Linear regression on x=generation and y=birthdate
        $sum_xy = 0;
        $sum_x=0;
        $sum_y=0;
        $sum_x2=0;
        $n=count($this->statistics_tab);
        foreach($this->statistics_tab as $gen=>$stats){
            $sum_xy+=$gen*$stats['avgBirth'];
            $sum_x+=$gen;
            $sum_y+=$stats['avgBirth'];
            $sum_x2+=$gen*$gen;
        }
        $denom=($n*$sum_x2)-($sum_x*$sum_x);
        if($denom!=0){
            return -(($n*$sum_xy)-($sum_x*$sum_y))/($denom);
        }
        return null;
    }
public function getMeanGenerationTime ( ) { if ( ! $ this -> is_setup ) return ; if ( ! $ this -> statistics_tab ) { $ this -> getStatisticsByGeneration ( ) ; } //Linear regression on x=generation and y=birthdate $ sum_xy = 0 ; $ sum_x = 0 ; $ sum_y = 0 ; $ sum_x2 = 0 ; $ n = count ( $ this -> statistics_tab ) ; foreach ( $ this -> statistics_tab as $ gen => $ stats ) { $ sum_xy += $ gen * $ stats [ 'avgBirth' ] ; $ sum_x += $ gen ; $ sum_y += $ stats [ 'avgBirth' ] ; $ sum_x2 += $ gen * $ gen ; } $ denom = ( $ n * $ sum_x2 ) - ( $ sum_x * $ sum_x ) ; if ( $ denom != 0 ) { return - ( ( $ n * $ sum_xy ) - ( $ sum_x * $ sum_y ) ) / ( $ denom ) ; } return null ; }
Get the mean generation time, based on a linear regression of birth years and generations

@return number|NULL Mean generation time
Get the mean generation time based on a linear regression of birth years and generations