Slight cleanup for mathutils
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3042 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
b221ce94ce
commit
56092a0fc2
|
|
@ -122,7 +122,7 @@ public class TrioGenotyperWalker extends RefWalker<VariantContext, Integer>{
|
|||
}
|
||||
}
|
||||
|
||||
double[] posteriors = MathUtils.log10posteriorsFromLog10L(L);
|
||||
double[] posteriors = MathUtils.normalizeFromLog10(L, true);
|
||||
log10POfGenotype = posteriors[bestIndex];
|
||||
}
|
||||
//log10POfViolation = Math.min(log10POfViolation, 0);
|
||||
|
|
|
|||
|
|
@ -277,9 +277,13 @@ public class MathUtils {
|
|||
|
||||
/**
|
||||
* normalizes the log10-based array
|
||||
*
|
||||
* @param array the array to be normalized
|
||||
* @param takeLog10OfOutput if true, the output will be transformed back into log10 units
|
||||
*
|
||||
* @return a newly allocated array corresponding the normalized values in array, maybe log10 transformed
|
||||
*/
|
||||
public static double[] normalizeFromLog10(double[] array) {
|
||||
public static double[] normalizeFromLog10(double[] array, boolean takeLog10OfOutput) {
|
||||
double[] normalized = new double[array.length];
|
||||
|
||||
// for precision purposes, we need to add (or really subtract, since they're
|
||||
|
|
@ -292,9 +296,16 @@ public class MathUtils {
|
|||
double sum = 0.0;
|
||||
for (int i = 0; i < array.length; i++)
|
||||
sum += normalized[i];
|
||||
for (int i = 0; i < array.length; i++)
|
||||
normalized[i] /= sum;
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
double x = normalized[i] / sum;
|
||||
if ( takeLog10OfOutput ) x = Math.log10(x);
|
||||
normalized[i] = x;
|
||||
}
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
public static double[] normalizeFromLog10(double[] array) {
|
||||
return normalizeFromLog10(array, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue