/// <summary>VMP 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 BernoulliIntegerSubset SampleAverageLogarithm(ISparseList <double> probTrue, BernoulliIntegerSubset result)
        {
            Func <double, Bernoulli> f = BernoulliFromBetaOp.SampleAverageLogarithm;

            result.SetTo(f.Map(probTrue));
            return(result);
        }
        /// <summary>VMP 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 the exponential of the average log-factor value, where the average is over all arguments except <c>sample</c>. The formula is <c>exp(sum_(probTrue) p(probTrue) log(factor(sample,probTrue)))</c>.</para>
        /// </remarks>
        /// <exception cref="ImproperMessageException">
        ///   <paramref name="probTrue" /> is not a proper distribution.</exception>
        public static BernoulliIntegerSubset SampleAverageLogarithm([SkipIfUniform] SparseBetaList probTrue, BernoulliIntegerSubset result)
        {
            Func <Beta, Bernoulli> f = BernoulliFromBetaOp.SampleAverageLogarithm;

            result.SetTo(f.Map(probTrue));
            return(result);
        }
        /// <summary>Gibbs 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 BernoulliIntegerSubset SampleConditional(ISparseList <double> probTrue, BernoulliIntegerSubset result)
        {
            Func <double, Bernoulli> f = BernoulliFromBetaOp.SampleConditional;

            result.SetTo(f.Map(probTrue));
            return(result);
        }