package HypoTest;
###########################################
# Hypotest - Testing hypotheses
# 2014, Mike Schilli <m@perlmeister.com>
###########################################
use Moose;
use Distrib;

has 'distrib' => ( 
    is => 'rw', 
    isa => 'Distrib', 
    default => sub { Distrib->new() } );

sub hypo_add {
  my( $self, $hypo ) = @_;

  $self->distrib()->set( $hypo, 1 );
}

sub update {
  my( $self, $data ) = @_;

  my $hypos = $self->distrib()->values();

  for my $hypo ( keys %$hypos ) {
    $self->distrib()->mult( $hypo,
      $self->likelihood( $data, $hypo ) 
    );
  }

  $self->distrib()->normalize();
}

sub print {
  my( $self ) = @_;

  my $values = $self->distrib()->values();

  for my $hypo ( keys %$values ) {
    print "$hypo: $values->{ $hypo }\n";
  }
}

sub likelihood {
    die "Subclass needs to override this";
}

1;
