/// <summary>EP message to <c>sample</c>.</summary>
 /// <param name="probTrue">Incoming message from <c>probTrue</c>. Must be a proper distribution. If any element is uniform, the result will be uniform.</param>
 /// <param name="result">Modified to contain the outgoing message.</param>
 /// <returns>
 ///   <paramref name="result" />
 /// </returns>
 /// <remarks>
 ///   <para>The outgoing message is a distribution matching the moments of <c>sample</c> as the random arguments are varied. The formula is <c>proj[p(sample) sum_(probTrue) p(probTrue) factor(sample,probTrue)]/p(sample)</c>.</para>
 /// </remarks>
 /// <exception cref="ImproperMessageException">
 ///   <paramref name="probTrue" /> is not a proper distribution.</exception>
 public static SparseBernoulliList SampleAverageConditional([SkipIfUniform] SparseBetaList probTrue, SparseBernoulliList result)
 {
     result.SetToFunction(probTrue, pt => BernoulliFromBetaOp.SampleAverageConditional(pt));
     return(result);
 }
 /// <summary>EP message to <c>sample</c>.</summary>
 /// <param name="probTrue">Constant value for <c>probTrue</c>.</param>
 /// <param name="result">Modified to contain the outgoing message.</param>
 /// <returns>
 ///   <paramref name="result" />
 /// </returns>
 /// <remarks>
 ///   <para>The outgoing message is the factor viewed as a function of <c>sample</c> conditioned on the given values.</para>
 /// </remarks>
 public static SparseBernoulliList SampleAverageConditional(ISparseList <double> probTrue, SparseBernoulliList result)
 {
     result.SetToFunction(probTrue, pt => BernoulliFromBetaOp.SampleAverageConditional(pt));
     return(result);
 }