734. Unnecessary restriction in [rand.dist.norm.chisq]

Section: 29.5.9.5.3 [rand.dist.norm.chisq] Status: CD1 Submitter: Stephan Tolksdorf Opened: 2007-09-21 Last modified: 2016-01-28

Priority: Not Prioritized

View all issues with CD1 status.

Discussion:

chi_squared_distribution, fisher_f_distribution and student_t_distribution have parameters for the "degrees of freedom" n and m that are specified as integers. For the following two reasons this is an unnecessary restriction: First, in many applications such as Bayesian inference or Monte Carlo simulations it is more convenient to treat the respective param- eters as continuous variables. Second, the standard non-naive algorithms (i.e. O(1) algorithms) for simulating from these distributions work with floating-point parameters anyway (all three distributions could be easily implemented using the Gamma distribution, for instance).

Similar arguments could in principle be made for the parameters t and k of the discrete binomial_distribution and negative_binomial_distribution, though in both cases continuous parameters are less frequently used in practice and in case of the binomial_distribution the implementation would be significantly complicated by a non-discrete parameter (in most implementations one would need an approximation of the log-gamma function instead of just the log-factorial function).

Possible resolution: For these reasons, I propose to change the type of the respective parameters to double.

[ Bellevue: ]

In N2424. Not wildly enthusiastic, not really felt necessary. Less frequently used in practice. Not terribly bad either. Move to OPEN.

[ Sophia Antipolis: ]

Marc Paterno: The generalizations were explicitly left out when designing the facility. It's harder to test.

Marc Paterno: Ask implementers whether floating-point is a significant burden.

Alisdair: It's neater to do it now, do ask Bill Plauger.

Disposition: move to review with the option for "NAD" if it's not straightforward to implement; unanimous consent.

Proposed resolution:

See N2424 for the proposed resolution.

[ Stephan Tolksdorf adds pre-Bellevue: ]

In 29.5.9.5.3 [rand.dist.norm.chisq]:

Delete ", where n is a positive integer" in the first paragraph.

Replace both occurrences of "explicit chi_squared_distribution(int n = 1);" with "explicit chi_squared_distribution(RealType n = 1);".

Replace both occurrences of "int n() const;" with "RealType n() const;".

In 29.5.9.5.5 [rand.dist.norm.f]:

Delete ", where m and n are positive integers" in the first paragraph.

Replace both occurrences of

explicit fisher_f_distribution(int m = 1, int n = 1);

with

explicit fisher_f_distribution(RealType m = 1, RealType n = 1);

Replace both occurrences of "int m() const;" with "RealType m() const;".

Replace both occurrences of "int n() const;" with "RealType n() const;".

In 29.5.9.5.6 [rand.dist.norm.t]:

Delete ", where n is a positive integer" in the first paragraph.

Replace both occurrences of "explicit student_t_distribution(int n = 1);" with "explicit student_t_distribution(RealType n = 1);".

Replace both occurrences of "int n() const;" with "RealType n() const;".