numRecipes
public class PoissonBinnedLikelihoodCalculator extends java.lang.Object implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
boolean |
debugFlag |
static double |
default_precision |
protected double |
poissonLogLikelihood |
protected java.util.Map |
realDataMap
Map container for (N_i, \mu_i).
|
protected java.util.Map |
replicaDataMap |
protected boolean |
useTheReplicaResults |
Constructor and Description |
---|
PoissonBinnedLikelihoodCalculator()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addExpectedNumbers(double signalFactor,
PoissonBinnedLikelihoodCalculator calSignal)
Add the expected number in calSignal to the internal map to this object.
|
void |
addExpectedNumbers(PoissonBinnedLikelihoodCalculator calSignal)
Add the expected number in calSignal to the internal map to this object.
|
void |
copyExpectedNumbers(double signalFactor,
PoissonBinnedLikelihoodCalculator calSignal)
Copy the expected number in calSignal to the internal map to this object.
|
void |
copyExpectedNumbers(PoissonBinnedLikelihoodCalculator calSignal)
Copy the expected number in calSignal to the internal map to this object.
|
void |
copyObservedNumbers(PoissonBinnedLikelihoodCalculator calSignal)
Copy the observed number in calSignal to the internal map to this object.
|
void |
copyPoissonBinnedData(PoissonBinnedLikelihoodCalculator cal)
copy the Poisson bin data (observed number, expected number) stored in PoissonBinnedLikelihoodCalculator cal.
|
void |
copyPoissonBinnedDataMap(java.util.Map poissonDataMap)
copy the Map containing the Poisson binned data.
|
void |
copyTheReplicaResults()
This method copies the map to store the results frmo the replica experiment to the map for storing the real results.
|
void |
fillData()
Reading a series of (N_i, \mu_i) from the standard input by the interactive methof
|
void |
fillData(java.io.DataInputStream in)
Reading a series of (N_i, \mu_i) from the input stream.
|
double |
getLikelihood()
Calculate the likelihood to the series of (N_i, mu_i).
|
double |
getLikelihood(double scaleFactor)
Calculate the likelihood to the series of (N_i, mu_i*scale_factor).
|
double |
getLikelihood(double scaleFactor,
double signalFactor,
PoissonBinnedLikelihoodCalculator calSignal)
Calculate the likelihood to the series of (N_i, bg_mu_i+sig_mu_i*signalFactor).
|
static double |
getLogPoissonProbability(long nObserved,
double expectedValue)
Calculate -log(Poisson) for a given set of (nObserved,expectedValue).
|
double |
getPvalue()
Calculate the p-value of the experiment to yield the series of bins (N_obs, \mu_i) with
the default_precision.
|
double |
getPvalue(double precision,
double scaleFactor)
Calculate the p-value of the experiment to yield the series of bins (N_obs, \mu_i).
|
double |
getSignalFactor(double scaleFactor,
PoissonBinnedLikelihoodCalculator calSignal)
Calculate the signalFactor to maximize likelihood to the series of (N_i, bg_mu_i+sig_mu_i*signalFactor).
|
double |
getSumOfExpectedValues()
Return the sum of the expected values \mu_i.
|
long |
getSumOfObservedValues()
Return the sum of the observed numbers \N_i.
|
static PoissonBinnedLikelihoodCalculator |
inputPoissonBinnedLikelihoodCalculator(java.io.InputStream in) |
static void |
main(java.lang.String[] args)
A simple main method
|
static void |
outputPoissonBinnedLikelihoodCalculator(PoissonBinnedLikelihoodCalculator cal,
java.io.OutputStream out) |
void |
printLogLikelihood() |
void |
printLogLikelihood(boolean printData)
print out the calculated Poisson binned log likelihood to the standard output
|
void |
replaceExpectedNumbersWithObservedNumbers()
Replace the expected number with the observed number so that
the expected number vector exactly equals to the observed number vector.
|
void |
replaceExpectedNumbersWithObservedNumbers(PoissonBinnedLikelihoodCalculator calBase)
Replace the expected number with the observed number - expected number in calBase so that
the expected number vector maximizes the likelihood under the conditaion that
the minimum expected numbers are bounded by the expected numbers stored in calBase.
|
protected void |
runPoissonExperiment()
This method is purely for debugging purposes.
|
double |
runReplicaExperiment()
Run replica expetiment one time following the Poissonian to the series of (N_i, mu_i).
|
double |
runReplicaExperiment(double scaleFactor)
Run replica expetiment one time following the Poissonian to the series of (N_i, mu_i).
|
void |
useTheResultsByTheRealExperiment()
call this method before calling the getLikelihood method if you want to calculate the log likelihood by
the real results read by the method fillData().
|
void |
useTheResultsByTheReplicaExperiment()
call this method before calling the getLikelihood method if you want to calculate the log likelihood by
the results by the replica experiment you had run withe the method runReplicaExperiment()
|
protected boolean useTheReplicaResults
public static final double default_precision
protected java.util.Map realDataMap
protected java.util.Map replicaDataMap
protected double poissonLogLikelihood
public boolean debugFlag
public PoissonBinnedLikelihoodCalculator()
public static double getLogPoissonProbability(long nObserved, double expectedValue)
public void fillData(java.io.DataInputStream in) throws java.io.IOException
nObserved_0 Expected-value_0 nObserved_1 Expected-value_1 .....You need a "space" before each end of line.
java.io.IOException
public void fillData() throws java.io.IOException
java.io.IOException
public void printLogLikelihood(boolean printData)
public void printLogLikelihood()
public double getSumOfExpectedValues()
public long getSumOfObservedValues()
public void copyPoissonBinnedData(PoissonBinnedLikelihoodCalculator cal)
public void copyPoissonBinnedDataMap(java.util.Map poissonDataMap)
Map((Integer)BinNumber, LinkedHashMap((Long)Observed Number, (Double)Expected Number))
public double runReplicaExperiment(double scaleFactor)
double scaleFactor: scaleFactor which is multiplied to mu_i; if set to 1.0, no fudge factor is introduced.
public double runReplicaExperiment()
public void useTheResultsByTheReplicaExperiment()
public void useTheResultsByTheRealExperiment()
public void copyTheReplicaResults()
public double getLikelihood(double scaleFactor)
double scaleFactor: scaleFactor which is multiplied to mu_i; if set to 1.0, no fudge factor is introduced.
public double getLikelihood(double scaleFactor, double signalFactor, PoissonBinnedLikelihoodCalculator calSignal)
double scaleFactor: scaleFactor which is multiplied to bg_mu_i; if set to 1.0, no fudge factor is introduced.
public double getSignalFactor(double scaleFactor, PoissonBinnedLikelihoodCalculator calSignal)
double scaleFactor: scaleFactor which is multiplied to bg_mu_i; if set to 1.0, no fudge factor is introduced.
public double getLikelihood()
public void copyObservedNumbers(PoissonBinnedLikelihoodCalculator calSignal)
public void copyExpectedNumbers(double signalFactor, PoissonBinnedLikelihoodCalculator calSignal)
public void copyExpectedNumbers(PoissonBinnedLikelihoodCalculator calSignal)
public void addExpectedNumbers(double signalFactor, PoissonBinnedLikelihoodCalculator calSignal)
public void addExpectedNumbers(PoissonBinnedLikelihoodCalculator calSignal)
public void replaceExpectedNumbersWithObservedNumbers()
public void replaceExpectedNumbersWithObservedNumbers(PoissonBinnedLikelihoodCalculator calBase)
public double getPvalue(double precision, double scaleFactor)
double precision : precision you want to caluclate p-value. Running replica expetiments 1/precision times to compute p-value.
public double getPvalue()
protected void runPoissonExperiment()
public static void outputPoissonBinnedLikelihoodCalculator(PoissonBinnedLikelihoodCalculator cal, java.io.OutputStream out) throws java.io.IOException
java.io.IOException
public static PoissonBinnedLikelihoodCalculator inputPoissonBinnedLikelihoodCalculator(java.io.InputStream in) throws java.io.IOException
java.io.IOException
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException