<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 734: Unnecessary restriction in [rand.dist.norm.chisq]</title>
<meta property="og:title" content="Issue 734: Unnecessary restriction in [rand.dist.norm.chisq]">
<meta property="og:description" content="C++ library issue. Status: CD1">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue734.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#CD1">CD1</a> status.</em></p>
<h3 id="734"><a href="lwg-defects.html#734">734</a>. Unnecessary restriction in [rand.dist.norm.chisq]</h3>
<p><b>Section:</b> 29.5.9.5.3 <a href="https://wg21.link/rand.dist.norm.chisq">[rand.dist.norm.chisq]</a> <b>Status:</b> <a href="lwg-active.html#CD1">CD1</a>
 <b>Submitter:</b> Stephan Tolksdorf <b>Opened:</b> 2007-09-21 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#CD1">CD1</a> status.</p>
<p><b>Discussion:</b></p>
<p>
<code>chi_squared_distribution</code>, <code>fisher_f_distribution</code> and <code>student_t_distribution</code>
have parameters for the "degrees of freedom" <code>n</code> and <code>m</code> 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).
</p>

<p>
Similar arguments could in principle be made for the parameters <code>t</code> and <code>k</code> of the discrete 
<code>binomial_distribution</code> and <code>negative_binomial_distribution</code>, though in both cases continuous
parameters are less frequently used in practice and in case of the <code>binomial_distribution</code>
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).
</p>

<p>
<b>Possible resolution:</b> For these reasons, I propose to change the type of the respective parameters 
to double.
</p>

<p><i>[
Bellevue:
]</i></p>


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

<p><i>[
Sophia Antipolis:
]</i></p>


<blockquote>
<p>
Marc Paterno: The generalizations were explicitly left out when designing the facility. It's harder to test.
</p>
<p>
Marc Paterno: Ask implementers whether floating-point is a significant burden.
</p>
<p>
Alisdair: It's neater to do it now, do ask Bill Plauger.
</p>
<p>
Disposition: move to review with the option for "NAD" if it's not straightforward to implement; unanimous consent.
</p>
</blockquote>



<p id="res-734"><b>Proposed resolution:</b></p>
<p>
See <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2424.pdf">N2424</a>
for the proposed resolution.
</p>

<p><i>[
Stephan Tolksdorf adds pre-Bellevue:
]</i></p>


<blockquote>
<p>
In 29.5.9.5.3 <a href="https://wg21.link/rand.dist.norm.chisq">[rand.dist.norm.chisq]</a>:
</p>

<blockquote>
<p>
Delete ", where <code>n</code> is a positive integer" in the first paragraph.
</p>

<p>
Replace both occurrences of "<code>explicit chi_squared_distribution(int n = 1);</code>"
with "<code>explicit chi_squared_distribution(RealType n = 1);</code>".
</p>

<p>
Replace both occurrences of "<code>int n() const;</code>" with "<code>RealType n() const;</code>".
</p>

</blockquote>

<p>
In 29.5.9.5.5 <a href="https://wg21.link/rand.dist.norm.f">[rand.dist.norm.f]</a>:
</p>
<blockquote>
<p>
Delete ", where <code>m</code> and <code>n</code> are positive integers" in the first paragraph.
</p>

<p>
Replace both occurrences of
</p>
<blockquote><pre>
explicit fisher_f_distribution(int m = 1, int n = 1);
</pre></blockquote>
<p>
with
</p>
<blockquote><pre>
explicit fisher_f_distribution(RealType m = 1, RealType n = 1);
</pre></blockquote>

<p>
Replace both occurrences of "<code>int m() const;" with "RealType m() const;</code>".
</p>

<p>
Replace both occurrences of "<code>int n() const;" with "RealType n() const;</code>".
</p>
</blockquote>

<p>
In 29.5.9.5.6 <a href="https://wg21.link/rand.dist.norm.t">[rand.dist.norm.t]</a>:
</p>

<blockquote>
<p>
Delete ", where <code>n</code> is a positive integer" in the first paragraph.
</p>

<p>
Replace both occurrences of "<code>explicit student_t_distribution(int n = 1);</code>"
with "<code>explicit student_t_distribution(RealType n = 1);</code>".
</p>

<p>
Replace both occurrences of "<code>int n() const;</code>" with "<code>RealType n() const;</code>".
</p>
</blockquote>

</blockquote>





</body>
</html>
