You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex Herbert (Jira)" <ji...@apache.org> on 2026/08/21 21:28:00 UTC
[jira] [Created] (RNG-195) DirichletSampler has unbounded recursion and stack overflow for small alpha parameters
Alex Herbert created RNG-195:
--------------------------------
Summary: DirichletSampler has unbounded recursion and stack overflow for small alpha parameters
Key: RNG-195
URL: https://issues.apache.org/jira/browse/RNG-195
Project: Commons RNG
Issue Type: Bug
Components: sampling
Affects Versions: 1.3
Reporter: Alex Herbert
The DirichletSampler uses a rejection method to sample. A gamma sample is obtained for each concentration parameter alpha. The vector of k samples is normalised to unit length. When the sum of the samples is zero or infinite the sample cannot be normalised and recursion occurs to generate another sample.
If the alpha parameters are very small the gamma samples are always zero and a stack overflow error occurs.
Note that recursion is expected to be used to indicate a non-functional RNG underlying the sampler. It was not the original intention to use a stack overflow error to indicate a badly parameterised sampler where samples are impossible.
Issue identified using a security scan.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)