Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /proc/thread-self/root/usr/share/perl5/Statistics/Basic/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/thread-self/root/usr/share/perl5/Statistics/Basic/Mean.pm
package Statistics::Basic::Mean;

use strict;
use warnings;
use Carp;

use base 'Statistics::Basic::_OneVectorBase';

sub new {
    my $class = shift;

    warn "[new $class]\n" if $Statistics::Basic::DEBUG >= 2;

    my $this   = bless {}, $class;
    my $vector = eval { Statistics::Basic::Vector->new(@_) } or croak $@;
    my $c      = $vector->_get_computer("mean"); return $c if defined $c;

    $this->{v} = $vector;

    $vector->_set_computer( mean => $this );

    return $this;
}

sub _recalc {
    my $this = shift;
    my $sum = 0;
    my $v = $this->{v};
    my $cardinality = $v->query_size;

    delete $this->{recalc_needed};
    delete $this->{_value};

    return unless $cardinality > 0;
    return unless $v->query_filled; # only applicable in certain circumstances

    { no warnings 'uninitialized'; ## no critic
      $sum += $_ for $v->query;
    }

    $this->{_value} = ($sum / $cardinality);

    warn "[recalc " . ref($this) . "] ($sum/$cardinality) = $this->{_value}\n" if $Statistics::Basic::DEBUG;

    return;
}

1;

Hry