Skip to content

Negative Binomial parameter wrong #263

Description

@colinfang
        /// <summary>
        /// Initializes a new instance of the <see cref="NegativeBinomial"/> class.
        /// </summary>
        /// <param name="r">The number of failures (r) until the experiment stopped. Range: r ≥ 0.</param>
        /// <param name="p">The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.</param>
        public NegativeBinomial(double r, double p)
        {
            if (!IsValidParameterSet(r, p))
            {
                throw new ArgumentException(Resources.InvalidDistributionParameters);
            }

            _random = SystemRandomSource.Default;
            _p = p;
            _trials = r;
        }

So here p is said to be success chance.

However, here:

 /// <summary>
        /// Gets the mean of the distribution.
        /// </summary>
        public double Mean
        {
            get { return _trials*(1.0 - _p)/_p; }
        }

According to wiki, it should be _trials * _p / (1 - _p) if we follow the description of the parameter.

It seems throughout the code we interpret _p as 1 - _p

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions