Ejemplo n.º 1
0
 private double NormalizedError(
     PatternFeature feature, double modelValue, double minError, double maxError) {
   if (feature.isRange()) {
     return StatUtil.calculate0to1NormalizedError(
         feature.getValueMin(), feature.getValueMax(), modelValue, minError, maxError);
   } else {
     return StatUtil.calculate0to1NormalizedError(
         feature.getValue(), modelValue, minError, maxError);
   }
 }
Ejemplo n.º 2
0
  public double sfaError() {

    int nPieceWiseParmsExp = expSpikePatternData.getSpikePatternClass().getnPieceWiseParms();
    int nPieceWiseParmsModel = patternClassifier.getSpikePatternClass().getnPieceWiseParms();
    double possibleWeightForFutureNEAR = nPieceWiseParmsExp - nPieceWiseParmsModel; // coarse!!

    double error = 0;
    double minError = 0;
    double maxMerror = 1;
    double maxCerror = 2;
    double maxNsfaError = expSpikePatternData.getCurrentDuration() * 0.3;

    SolverResultsStat modelStats =
        patternClassifier.getSolverResultsStats()[nPieceWiseParmsExp - 1];
    int modelNsfaISIs1 = modelStats.getBreakPoint();
    int modelNsfaISIs2 = modelSpikePattern.getISIs().length - modelNsfaISIs1;
    double[] model =
        new double[] {
          modelStats.getM1(),
          modelStats.getM2(),
          modelStats.getC1(),
          modelStats.getC2(),
          modelNsfaISIs1,
          modelNsfaISIs2
        };
    double[] exp =
        new double[] {
          expSpikePatternData.getSfaLinearM1().getValue(),
          expSpikePatternData.getSfaLinearM2().getValue(),
          expSpikePatternData.getSfaLinearb1().getValue(),
          expSpikePatternData.getSfaLinearb2().getValue(),
          expSpikePatternData.getNSfaISIs1().getValue(),
          expSpikePatternData.getNSfaISIs2().getValue(),
        };

    for (int i = 0; i < 6; i++) {
      if (i < 2) { // slopes
        error += StatUtil.calculate0to1NormalizedError(exp[i], model[i], minError, maxMerror);
      } else {
        if (i < 4) { // intercepts
          error += StatUtil.calculate0to1NormalizedError(exp[i], model[i], minError, maxCerror);
        } else {
          error += StatUtil.calculate0to1NormalizedError(exp[i], model[i], minError, maxNsfaError);
        }
      }
    }

    error =
        patternClassifier.getDynamicFeatWeightMatrix().get(PatternFeatureID.n_sfa_isis2) * error;

    if (display) {
      displayRoutineForSFA(null, model, error);
    }
    return error;
  }