src/utils/procedure/expression/VarianceExpression.java
public void calculateGradient(int sampleIndex) throws MatrixException {
        if (executeAsSingleStep()) return;
        if (result.getGradient(sampleIndex) == null) throw new MatrixException(getExpressionName() + ": Result gradient not defined.");
        Matrix varianceGradient = argument1.getMatrix(sampleIndex).subtract(means.get(sampleIndex)).multiply(2 / (double)argument1.getMatrix(sampleIndex).size());
        argument1.cumulateGradient(sampleIndex, result.getGradient(sampleIndex).multiply(varianceGradient), false);
        means.remove(sampleIndex);
    }
/**
     * Calculates gradient of expression.
     *
     * @param sampleIndex sample index
     * @throws MatrixException throws exception if calculation of gradient fails.
     */
Calculates gradient of expression.
@param sampleIndex sample index
@throws MatrixException throws exception if calculation of gradient fails.
Calculates gradient of expression . @param sampleIndex sample index @throws MatrixException throws exception if calculation of gradient fails .
public void calculateGradient(int sampleIndex) throws MatrixException {
        if (executeAsSingleStep()) return;
        if (result.getGradient(sampleIndex) == null) throw new MatrixException(getExpressionName() + ": Result gradient not defined.");
        Matrix varianceGradient = argument1.getMatrix(sampleIndex).subtract(means.get(sampleIndex)).multiply(2 / (double)argument1.getMatrix(sampleIndex).size());
        argument1.cumulateGradient(sampleIndex, result.getGradient(sampleIndex).multiply(varianceGradient), false);
        means.remove(sampleIndex);
    }
public void calculateGradient ( int sampleIndex ) throws MatrixException { if ( executeAsSingleStep ( ) ) return ; if ( result . getGradient ( sampleIndex ) == null ) throw new MatrixException ( getExpressionName ( ) + ": Result gradient not defined." ) ; Matrix varianceGradient = argument1 . getMatrix ( sampleIndex ) . subtract ( means . get ( sampleIndex ) ) . multiply ( 2 / ( double ) argument1 . getMatrix ( sampleIndex ) . size ( ) ) ; argument1 . cumulateGradient ( sampleIndex , result . getGradient ( sampleIndex ) . multiply ( varianceGradient ) , false ) ; means . remove ( sampleIndex ) ; }
Calculates gradient of expression.
Calculates gradient of expression .