code: public Map<Integer, RandomVariable> getGradient(){
  
  		int numberOfCalculationSteps = getFunctionList().size();
  
  		RandomVariable[] omegaHat = new RandomVariable[numberOfCalculationSteps];
  
  		omegaHat[numberOfCalculationSteps-1] = new RandomVariableFromDoubleArray(1.0);
  
  		for(int variableIndex = numberOfCalculationSteps-2; variableIndex >= 0; variableIndex--){
  
  			omegaHat[variableIndex] = new RandomVariableFromDoubleArray(0.0);
  
  			ArrayList<Integer> childrenList = getAADRandomVariableFromList(variableIndex).getChildrenIndices();
  
  			for(int functionIndex:childrenList){
  				RandomVariable D_i_j = getPartialDerivative(functionIndex, variableIndex);
  				omegaHat[variableIndex] = omegaHat[variableIndex].addProduct(D_i_j, omegaHat[functionIndex]);
  			}
  		}
  
  		ArrayList<Integer> arrayListOfAllIndicesOfDependentRandomVariables = getArrayListOfAllIndicesOfDependentRandomVariables();
  
  		Map<Integer, RandomVariable> gradient = new HashMap<Integer, RandomVariable>();
  
  		for(Integer indexOfDependentRandomVariable: arrayListOfAllIndicesOfDependentRandomVariables){
  			gradient.put(indexOfDependentRandomVariable, omegaHat[arrayListOfAllIndicesOfDependentRandomVariables.get(indexOfDependentRandomVariable)]);
  		}
  
  		return gradient;
  	}
docs: Implements the AAD Algorithm
  @return HashMap where the key is the internal index of the random variable with respect to which the partial derivative was computed. This key then gives access to the actual derivative.