/// <summary>Computations that depend on the observed value of wPrior and xIndices and xValueCount</summary> public void Changed_wPrior_xIndices_xValueCount() { if (this.Changed_wPrior_xIndices_xValueCount_iterationsDone == 1) { return; } this.wSparse_F = SubarrayOp <double> .ItemsAverageConditional <Gaussian, DistributionStructArray <Gaussian, double> >(this.WPrior, this.XIndices, this.wSparse_F); this.Changed_wPrior_xIndices_xValueCount_iterationsDone = 1; this.Changed_xValueCount_xValues_wPrior_xIndices_iterationsDone = 0; this.Changed_y_biasPrior_xValueCount_xValues_wPrior_xIndices_iterationsDone = 0; }
/// <summary> /// Computes the inner product of the feature weights and values. /// </summary> /// <param name="weights">The feature weights.</param> /// <param name="nonZeroValues">The sparse feature values.</param> /// <param name="nonZeroIndices">The sparse feature indices.</param> /// <returns>The contribution of the features.</returns> private static Gaussian ComputeFeatureContribution(IList <Gaussian> weights, IList <double> nonZeroValues, IList <int> nonZeroIndices) { Debug.Assert(nonZeroValues.Count == nonZeroIndices.Count, "The number of values must be equal to the number of indices."); int count = nonZeroValues.Count; var nonZeroWeights = new Gaussian[count]; SubarrayOp <double> .ItemsAverageConditional(weights, nonZeroIndices, nonZeroWeights); var products = new List <Gaussian>(count); for (int i = 0; i < count; ++i) { products.Add(GaussianProductOp.ProductAverageConditional(nonZeroWeights[i], nonZeroValues[i])); } return(FastSumOp.SumAverageConditional(products)); }