# tscore.pm 
# package to calculate the t-score co-efficient.

# The T-score is defined as a ratio of difference between the observed
# and the expected mean to the variance of the sample. Note that this
# is a variant of the standard t-test that was proposed for use in the
# identification of collocations in large samples of text. 

# Copyright (C) 2001-2002.
# Nitin Varma, University of Minnesota, Duluth
# varm0003@d.umn.edu
# Ted Pedersen, University of Minnesota, Duluth
# tpederse@d.umn.edu
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


package tscore;
require Exporter;
@ISA = qw ( Exporter );
@EXPORT = qw ( getStatisticName calculateStatistic );

sub getStatisticName
{
    return "T-score";
}

sub calculateStatistic
{
    ($freq, $freq1, $freq2, $totalBigrams) = @_;
    $pairFreq =  $freq/$totalBigrams;
    $word1Freq = $freq1/$totalBigrams;
    $word2Freq = $freq2/$totalBigrams;
    $numerator = $pairFreq - ($word1Freq * $word2Freq);
    $denominator = sqrt(($pairFreq/$totalBigrams));
    return ( ( $numerator / $denominator ) );
}

1;






