Class LLR
This class is used to calculate a simple log likelihood ratio for a matrix
of counts over two variables that take discrete values.
There is no constructor.
All methods are static.
Author: Michael Towsey.
Assembly: TowseyLibrary.dll
Syntax
Methods
|
Improve this Doc
View Source
CalculateLogLikelihoodRatio(Double, Double)
See Wikipedia on LLR
-2log(Lambda) = -2LLR = 2log[p(x|B)/p(x|Bo)] = 2log[p(x|B)] - 2log[p(x|Bo)]
therefore LLR = log[p(x|Bo)] - log[p(x|B)]
where x is the observation.
where Bo are the parameters of the null hypothesis
where B are the parameters of alternative hypothesis.
Declaration
public static double CalculateLogLikelihoodRatio(double unigramLogScore, double bigramLogScore)
Parameters
Type |
Name |
Description |
Double |
unigramLogScore |
log likelihood of the null hypothesis.
|
Double |
bigramLogScore |
log likelihood of the alernative hypothesis.
|
Returns
|
Improve this Doc
View Source
CellExpectedValue(Int32[,], Int32, Int32, Int32)
Declaration
public static double CellExpectedValue(int[, ] table, int row, int column, int totalCount)
Parameters
Returns
|
Improve this Doc
View Source
ChiSquare(Int32[,], Double[,], out Double, out Int32)
Calculates the chi square statistic from a contingency table and the transition frequenices of a Markov Model.
See my statistics book for engineers and scientists, Walpole and Myers, p345.
Declaration
public static void ChiSquare(int[, ] contingencyTable, double[, ] expectedRf, out double chi2, out int df)
Parameters
|
Improve this Doc
View Source
ChiSquare_DF1(Double)
Declaration
public static double ChiSquare_DF1(double chi)
Parameters
Type |
Name |
Description |
Double |
chi |
|
Returns
|
Improve this Doc
View Source
ChiSquare_DFn(Double, Int32)
Declaration
public static double ChiSquare_DFn(double chi2, int df)
Parameters
Returns
|
Improve this Doc
View Source
ColumnRelativeFrequency(Int32[,], Int32, Int32)
Declaration
public static double ColumnRelativeFrequency(int[, ] table, int column, int totalCount)
Parameters
Returns
|
Improve this Doc
View Source
GetLLRs(Int32[,])
Declaration
public static double[, ] GetLLRs(int[, ] contingencyTable)
Parameters
Type |
Name |
Description |
Int32[,] |
contingencyTable |
|
Returns
|
Improve this Doc
View Source
RowRelativeFrequency(Int32[,], Int32, Int32)
Declaration
public static double RowRelativeFrequency(int[, ] table, int row, int totalCount)
Parameters
Returns
|
Improve this Doc
View Source
WriteLogLikelihoodRatioMatrix(Double[,])
Declaration
public static string WriteLogLikelihoodRatioMatrix(double[, ] m)
Parameters
Type |
Name |
Description |
Double[,] |
m |
|
Returns