package org.aika.training;


import org.aika.neuron.Activation;
import org.aika.neuron.INeuron;
import org.aika.neuron.Synapse;

public class SynapseSignificance {


    public static double sig(Synapse s) {
        return sig(s.input.get(), s.output.get());
    }


    public static double sig(Activation iAct, Activation oAct) {
        return sig(iAct.key.node.neuron.get(), oAct.key.node.neuron.get());
    }


    public static double sig(INeuron in, INeuron on) {
        if(on.type == INeuron.Type.INHIBITORY) {
            return 1.0;
        }

        int iFreq = ((NeuronStatistic) in.statistic).frequency;
        int oFreq = ((NeuronStatistic) on.statistic).frequency;
        return Math.pow(iFreq * oFreq, -0.2);
    }
}

@@ -563,24 +563,36 @@
  int iFreq =
+ Math.max(1,
  ((NeuronSta
@@ -614,32 +614,33 @@
 istic).frequency
+)
 ;%0A        int oF
@@ -644,16 +644,28 @@
  oFreq =
+ Math.max(1,
  ((Neuro
@@ -699,16 +699,17 @@
 requency
+)
 ;%0A      

fix synapse significance computation