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); } }
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; }
private double NormalizedErrorObsNormed(PatternFeature feature, double modelValue) { /* * the w here is manual weight assigned in JSON. only for special cases!! like 3-000 to get D.ASP. * shouldn't be confused with dynamic W calculated in spikepatternclassifier * Typically, w is 0 in JSON, so that this manual weight is ignored! */ double w = feature.getWeight(); if (GeneralUtils.isCloseEnough(w, 0, 0.001)) { w = 1; } if (feature.isRange()) { return w * StatUtil.calculateObsNormalizedError( feature.getValueMin(), feature.getValueMax(), modelValue); } else { return w * StatUtil.calculateObsNormalizedError(feature.getValue(), modelValue); } }
private float spikesBelowVrestError(float vR) { double avgBelowVrestOffset = modelSpikePattern.calculateAvgBelowVrest(vR); return (float) StatUtil.calculateObsNormalizedError(0, avgBelowVrestOffset); }
/* * other non-feature errors; like avoid bursting... */ private float nonBurstBelowVminError(float vMin) { double avgBelowVminOffset = modelSpikePattern.calculateAvgBelowVminAfterLastSpike(vMin, 200); return (float) StatUtil.calculateObsNormalizedError(0, avgBelowVminOffset); }
private double singleBurstError( int burstIdx, HashMap<BurstFeatureID, Double> expSingleBurstFeatures) { if (burstIdx >= modelSpikePattern.getBurstPattern().getNBursts()) { return 1; } double errorBW = 0; double errorIBI = 0; double errorNspikes = 0; // 2. BW error double bw = -1; if (expSingleBurstFeatures.containsKey(BurstFeatureID.b_w)) { bw = expSingleBurstFeatures.get(BurstFeatureID.b_w); double modelBw = modelSpikePattern.getBurstPattern().getBW(burstIdx); errorBW = StatUtil.calculateObsNormalizedError(bw, modelBw); } // 3. IBI error double pbi = -1; if (expSingleBurstFeatures.containsKey(BurstFeatureID.pbi)) { pbi = expSingleBurstFeatures.get(BurstFeatureID.pbi); double modelPbi = modelSpikePattern.getBurstPattern().getIBI(burstIdx); errorIBI = StatUtil.calculateObsNormalizedError(pbi, modelPbi); } // 4. N spikes error double nspikes = expSingleBurstFeatures.get(BurstFeatureID.nspikes); errorNspikes = StatUtil.calculateObsNormalizedError( nspikes, modelSpikePattern.getBurstPattern().getNSpikes(burstIdx)); /* * display */ if (display) { System.out.print("\t"); if (expSingleBurstFeatures.containsKey(BurstFeatureID.b_w)) { String displayString = "\tb_w\t" + GeneralUtils.formatTwoDecimal(bw); displayString += "\t" + GeneralUtils.formatTwoDecimal( modelSpikePattern.getBurstPattern().getBW(burstIdx)); displayString += "\t" + GeneralUtils.formatThreeDecimal(errorBW) + "\t/"; System.out.print(displayString); } if (expSingleBurstFeatures.containsKey(BurstFeatureID.pbi)) { String displayString = "\tibi\t" + GeneralUtils.formatTwoDecimal(pbi); displayString += "\t" + GeneralUtils.formatTwoDecimal( modelSpikePattern.getBurstPattern().getIBI(burstIdx)); displayString += "\t" + GeneralUtils.formatThreeDecimal(errorIBI) + "\t/"; System.out.print(displayString); } String displayString = "\tnspikes\t" + GeneralUtils.formatTwoDecimal(nspikes); displayString += "\t" + GeneralUtils.formatTwoDecimal( modelSpikePattern.getBurstPattern().getNSpikes(burstIdx)); displayString += "\t" + GeneralUtils.formatThreeDecimal(errorNspikes) + "\t/"; System.out.print(displayString + "\n"); } return ((expSpikePatternData.getBurstFeatures().getFeatureWeight(BurstFeatureID.b_w) * errorBW) + (expSpikePatternData.getBurstFeatures().getFeatureWeight(BurstFeatureID.pbi) * errorIBI) + (expSpikePatternData.getBurstFeatures().getFeatureWeight(BurstFeatureID.nspikes) * errorNspikes)); }