Gets the variance of the values of each assignment to
{@code featureVariableNum} in {@code featureFactors}.

@param featureFactors
@param featureVariableNum
@return
512700
public static DiscreteFactor getVariances(Collection<DiscreteFactor> featureFactors,
      int featureVariableNum) {
    DiscreteFactor means = getMeans(featureFactors, featureVariableNum);
    
    DiscreteFactor sumSquares = null;
    int numEntries = 0;
    for (DiscreteFactor featureFactor : featureFactors) {
      VariableNumMap nonFeatureVars = featureFactor.getVars().removeAll(featureVariableNum);
      numEntries += nonFeatureVars.getNumberOfPossibleAssignments();

      DiscreteFactor factorSumSquares = featureFactor.product(featureFactor)
          .marginalize(nonFeatureVars);
      if (sumSquares == null) {
        sumSquares = factorSumSquares;
      } else {
        sumSquares = sumSquares.add(factorSumSquares);
      }
    }
    
    return sumSquares.add(means.product(means).product(-1.0 * numEntries))
        .product(1.0 / numEntries);
  }
99433
public function getFeatureVariableFromKey($featureFlagKey, $variableKey)
    {
        $featureFlag = $this->getFeatureFlagFromKey($featureFlagKey);
        if ($featureFlag && !($featureFlag->getKey())) {
            return null;
        }

        if (isset($this->_featureFlagVariableMap[$featureFlagKey])
            && isset($this->_featureFlagVariableMap[$featureFlagKey][$variableKey])
        ) {
            return $this->_featureFlagVariableMap[$featureFlagKey][$variableKey];
        }

        $this->_logger->log(
            Logger::ERROR,
            sprintf(
                'No variable key "%s" defined in datafile for feature flag "%s".',
                $variableKey,
                $featureFlagKey
            )
        );
        $this->_errorHandler->handleError(
            new InvalidFeatureVariableException('Provided feature variable is not in datafile.')
        );
        return null;
    }
563644
public Set<Integer> getSharedVariables(int factor1, int factor2) {
    Set<Integer> varNums = new HashSet<Integer>(factorVariableMap.get(factor1));
    varNums.retainAll(factorVariableMap.get(factor2));
    return varNums;
  }
987207
@Override
	public RandomVariable getCovariance(int timeIndex, int component1, int component2, RandomVariable[] realizationAtTimeIndex) {

		RandomVariable volatilityOfComponent1 = volatilityModel.getVolatility(timeIndex, component1);
		RandomVariable volatilityOfComponent2 = volatilityModel.getVolatility(timeIndex, component2);

		double					correlationOfComponent1And2 = correlationModel.getCorrelation(timeIndex, component1, component2);

		RandomVariable covariance = volatilityOfComponent1.mult(volatilityOfComponent2).mult(correlationOfComponent1And2);

		return covariance;
	}
1082561
public int getFeatureShapeCount(String database, String table, long featureId) {
        return getFeatureShape(database, table, featureId).count();
    }
944140
public void addConstantFactor(String factorName, Factor factor) {
    if (variables.containsAll(factor.getVars())) {
      int factorNum = factors.size();
      factors.add(factor);
      factorNames.add(factorName);

      VariableNumMap factorVars = factor.getVars();
      for (Integer varNum : factorVars.getVariableNums()) {
        variableFactorMap.put(varNum, factorNum);
        factorVariableMap.put(factorNum, varNum);
      }
    } else {
      Preconditions.checkState(!isRoot);
      crossingFactors.add(factor);
    }
  }
1209020
public static List<Var> getVarsOfType(List<Var> vars, VarType type) {
        ArrayList<Var> subset = new ArrayList<Var>();
        for (Var v : vars) {
            if (v.getType() == type) {
                subset.add(v);
            }
        }
        return subset;      
    }
205340
public int ensureFeature(String featureName) {
        int feature = featureToIndex.getOrDefault(featureName, -1);
        if (feature == -1) {
            synchronized (featureToIndex) {
                feature = featureToIndex.getOrDefault(featureName, -1);
                if (feature == -1) {
                    feature = featureToIndex.size();
                    featureToIndex.put(featureName, feature);
                }
            }
        }
        return feature;
    }
699560
private Iterable<Issue> getDirectErrorsOrLogicallyContainedErrors(final JvmFeature feature) {
    Iterable<Issue> errors = this._errorSafeExtensions.getErrors(feature);
    boolean _isEmpty = IterableExtensions.isEmpty(errors);
    if (_isEmpty) {
      final XExpression expression = this._iLogicalContainerProvider.getAssociatedExpression(feature);
      if ((expression != null)) {
        errors = this._errorSafeExtensions.getErrors(expression);
      }
    }
    return errors;
  }
518262
@Override
  public List<VariableMatch> matchVariables(VariableNumMap inputVariables) {
    // All of the fixed variables must be matched in order to return anything.
    if (!inputVariables.containsAll(fixedVariables)) {
      return Collections.emptyList();
    }
    // Special case: if there aren't any templates, then only the fixed
    // variables should be returned.
    if (plateStarts.length == 0) {
      return Arrays.asList(VariableMatch.identity(fixedVariables));
    }

    int maxPlateReplication = -1;
    int[] inputVarNums = inputVariables.getVariableNumsArray();
    int numVars = inputVarNums.length;
    int numMatchers = plateStarts.length;
    for (int i = 0; i < numMatchers; i++) {
      for (int j = 0; j < numVars; j++) {
        if (inputVarNums[j] >= plateStarts[i] && inputVarNums[j] < plateEnds[i]) {
          int withinPlateIndex = inputVarNums[j] - plateStarts[i];
          int plateReplicationNum = withinPlateIndex / plateReplicationSizes[i];
          int replicationIndex = plateReplicationNum - plateMatchIndexOffsets[i];
          maxPlateReplication = Math.max(replicationIndex, maxPlateReplication);
        }
      }
    }

    // Aggregate pattern matches for each variable.
    int[] templateVarNums = templateVariables.getVariableNumsArray();
    int[][] variableMatches = new int[maxPlateReplication + 1][];
    for (int i = 0; i < numMatchers; i++) {      
      for (int j = 0; j < numVars; j++) {
        if (inputVarNums[j] >= plateStarts[i] && inputVarNums[j] < plateEnds[i]) {
          // The variable is within the plate we're matching.
          int withinPlateIndex = inputVarNums[j] - plateStarts[i];
          int plateReplicationNum = withinPlateIndex / plateReplicationSizes[i];
          int varOffset = withinPlateIndex % plateReplicationSizes[i];
          if (varOffset == plateVarOffsets[i]) {
            // The variable matches the pattern.
            int replicationIndex = plateReplicationNum - plateMatchIndexOffsets[i];
            if (variableMatches[replicationIndex] == null) {
              variableMatches[replicationIndex] = new int[templateVarNums.length];
              Arrays.fill(variableMatches[replicationIndex], -1);
            }
            variableMatches[replicationIndex][i] = inputVarNums[j];
          }
        }
      }
    }

    // Eliminate any partial matches which do not contain a match for every
    // variable prefix.
    List<VariableMatch> validMatches = Lists.newArrayList();
    int numMatches = variableMatches.length;
    for (int i = 0; i < numMatches; i++) {
      int[] matchBuilder = variableMatches[i];
      if (matchBuilder != null && Ints.indexOf(matchBuilder, -1) == -1) {
        VariableNumMap matchedVariables = inputVariables.intersection(matchBuilder);
        VariableRelabeling fixedVariableRelabeling = VariableRelabeling.identity(fixedVariables);

        int[] templateCopy = Arrays.copyOf(templateVarNums, templateVarNums.length);

        IntBiMap mapping = IntBiMap.fromUnsortedKeyValues(matchBuilder, templateCopy);
        VariableRelabeling matchedRelabeling = new VariableRelabeling(matchedVariables,
            templateVariables, mapping);
        VariableMatch match = new VariableMatch(matchedVariables.union(fixedVariables),
          templateVariables.union(fixedVariables), fixedVariableRelabeling.union(matchedRelabeling));

        validMatches.add(match);
      }
    }
    return validMatches;
  }
1125552
public final VariableNumMap getVariablesByName(Collection<String> variableNames) {
    int[] newNums = new int[nums.length];
    String[] newNames = new String[nums.length];
    Variable[] newVars = new Variable[nums.length];

    int numFilled = 0;
    for (int i = 0; i < nums.length; i++) {
      if (variableNames.contains(names[i])) {
        newNums[numFilled] = nums[i];
        newNames[numFilled] = names[i];
        newVars[numFilled] = vars[i];
        numFilled++;
      }
    }
    return VariableNumMap.fromSortedArrays(newNums, newNames, newVars, numFilled);
  }
894992
public int[] feature(double[] x) {
        if (x.length != attributes.length) {
            throw new IllegalArgumentException(String.format("Invalid feature vector size %d, expected %d", x.length, attributes.length));
        }
        
        int[] features = new int[attributes.length];
        for (int i = 0; i < features.length; i++) {
            int f = (int) x[i];
            if (Math.floor(x[i]) != x[i] || f < 0 || f >= attributes[i].size()) {
                throw new IllegalArgumentException(String.format("Invalid value of attribute %s: %d", attributes[i].toString(), f));
            }
            
            features[i] = f + base[i];
        }
        
        return features;
    }
1326396
private Feature getFeature(AnnotationFS annotation, FeatureDescription featureDescription) {
		if(feature == null) {
			String name = featureDescription.getName();
			feature = annotation.getType().getFeatureByBaseName(name);
		}
		return feature;
	}
640895
@SuppressWarnings("static-method")
	public void getImportedFeatures(List<Class<?>> features) {
		features.add(AtomicIntegerArithmeticExtensions.class);
		features.add(AtomicLongArithmeticExtensions.class);
		features.add(ByteArithmeticExtensions.class);
		features.add(DoubleArithmeticExtensions.class);
		features.add(FloatArithmeticExtensions.class);
		features.add(IntegerArithmeticExtensions.class);
		features.add(LongArithmeticExtensions.class);
		features.add(NumberArithmeticExtensions.class);
		features.add(PrimitiveByteArithmeticExtensions.class);
		features.add(PrimitiveDoubleArithmeticExtensions.class);
		features.add(PrimitiveFloatArithmeticExtensions.class);
		features.add(PrimitiveIntArithmeticExtensions.class);
		features.add(PrimitiveLongArithmeticExtensions.class);
		features.add(PrimitiveShortArithmeticExtensions.class);
		features.add(ShortArithmeticExtensions.class);
	}
832782
private ProvisioningFeatureDefinition getCachedFeature(String featureName) {
        List<ProvisioningFeatureDefinition> featureList = symbolicNameToFeature.get(featureName);

        if (featureList == null) {
            featureName = publicNameToSymbolicName.get(featureName.toLowerCase());
            if (featureName != null) {
                featureList = symbolicNameToFeature.get(featureName);
            }
        }

        if (featureList == null || featureList.isEmpty()) {
            return null;
        }

        return getPreferredVersion(featureName, featureList);
    }
485545
public static DiscreteFactor createIndicatorFeatureTensor(VariableNumMap vars, int featureVarNum,
      TableFactorBuilder initialWeights) {
    // The "name" of an indicator feature is the assignment that it indicates.
    List<List<Object>> features = Lists.newArrayList();
    Iterator<Assignment> assignmentIterator = initialWeights != null ?
        initialWeights.assignmentIterator() : new AllAssignmentIterator(vars);
    while (assignmentIterator.hasNext()) {
      features.add(assignmentIterator.next().getValues());
    }
    DiscreteVariable featureVariable = new DiscreteVariable("indicator features", features);
    VariableNumMap featureVarMap = VariableNumMap.singleton(featureVarNum, "features-" + featureVarNum,
        featureVariable);

    TableFactorBuilder featureValueBuilder = new TableFactorBuilder(vars.union(featureVarMap),
        SparseTensorBuilder.getFactory());
    for (List<Object> featureValues : features) {
      Assignment newAssignment = vars.outcomeToAssignment(featureValues)
          .union(featureVarMap.outcomeArrayToAssignment(featureValues));
      featureValueBuilder.setWeight(newAssignment, 1.0);
    }
    return featureValueBuilder.build().cacheWeightPermutations();
  }
726741
public final Variable getVariable(int variableNum) {
    int index = getVariableIndex(variableNum);
    if (index >= 0) {
      return vars[index];
    } else {
      return null;
    }
  }