<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 732: Defect in [rand.dist.samp.genpdf]</title>
<meta property="og:title" content="Issue 732: Defect in [rand.dist.samp.genpdf]">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue732.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#Resolved">Resolved</a> status.</em></p>
<h3 id="732"><a href="lwg-defects.html#732">732</a>. Defect in [rand.dist.samp.genpdf]</h3>
<p><b>Section:</b> 99 [rand.dist.samp.genpdf] <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</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 other</b> <a href="lwg-index.html#rand.dist.samp.genpdf">issues</a> in [rand.dist.samp.genpdf].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Duplicate of:</b> <a href="lwg-closed.html#795" title="general_pdf_distribution should be dropped (Status: Dup)">795</a></p>
<p><b>Discussion:</b></p>
<p>
99 [rand.dist.samp.genpdf] describes the interface for a distribution template that is 
meant to simulate random numbers from any general distribution given only the density and the 
support of the distribution. I'm not aware of any general purpose algorithm that would be capable 
of correctly and efficiently implementing the described functionality. From what I know, this is 
essentially an unsolved research problem. Existing algorithms either require more knowledge 
about the distribution and the problem domain or work only under very limited circumstances. 
Even the state of the art special purpose library UNU.RAN does not solve the problem in full 
generality, and in any case, testing and customer support for such a library feature would be a 
nightmare.
</p>

<p>
<b>Possible resolution:</b> For these reasons, I propose to delete section 99 [rand.dist.samp.genpdf].
</p>

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


<blockquote>
<p>
Disagreement persists.
</p>
<p>
Objection to this issue is that this function takes a general functor.
The general approach would be to normalize this function, integrate it,
and take the inverse of the integral, which is not possible in general.
An example function is sin(1+n*x) &mdash; for any spatial frequency that the
implementor chooses, there is a value of n that renders that choice
arbitrarily erroneous.
</p>
<p>
Correction: The formula above should instead read 1+sin(n*x).
</p>
<p>
Objector proposes the following possible compromise positions:
</p>
<ul>
<li>
rand.dist.samp.genpdf takes an number of points so that implementor need not guess.
</li>
<li>
replace rand.disk.samp.genpdf with an extension to either or both of the discrete 
functions to take arguments that take a functor and number of points in place of 
the list of probabilities. Reference issues 793 and 794.
</li>
</ul>
</blockquote>



<p id="res-732"><b>Proposed resolution:</b></p>
<p>
See <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2813.pdf">N2813</a>
for the proposed resolution.
</p>


<p><b>Rationale:</b></p><p>
Addressed by
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2836.pdf">N2836</a> 
"Wording Tweaks for Concept-enabled Random Number Generation in C++0X".
</p>




</body>
</html>
