package project.datapreprocess;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import utils.array.ArraySumUtil;

import java.util.stream.IntStream;

/**
 * Created by hanxuan on 11/3/15 for machine_learning.
 */
public class PriorNoBuzz extends Process{

    private static Logger log = LogManager.getLogger(PriorNoBuzz.class);

    @Override
    public void tableProcess(float[][] table) {

        float[] backgroundProbs = new float[table[0].length];
        for (int i = 0; i < table.length; i++)
            for (int j = 0; j < backgroundProbs.length; j++)
                backgroundProbs[j] += table[i][j];

        ArraySumUtil.normalize(backgroundProbs);

        for (int i = 0; i < table.length; i++) {
            float[] probs = ArraySumUtil.normalize(table[i]);
            IntStream.range(0, probs.length).forEach(j -> probs[j] /= backgroundProbs[j]);
        }

        log.info("tableProcess PriorNoBuzz");
        log.debug("backgroundProbs {}", backgroundProbs);
    }
}

@@ -877,10 +877,37 @@
 %5Bj%5D 
-/
 =
+ (float) Math.log(probs%5Bj%5D /
  bac
@@ -922,16 +922,17 @@
 robs%5Bj%5D)
+)
 ;%0A      

use log