You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles Sadowski (Jira)" <ji...@apache.org> on 2021/05/22 00:03:00 UTC
[jira] [Resolved] (MATH-1533) EnumeratedDistribution.sample()
depends on ordering of input even if RNG is given
[ https://issues.apache.org/jira/browse/MATH-1533?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gilles Sadowski resolved MATH-1533.
-----------------------------------
Resolution: Feedback Received
> EnumeratedDistribution.sample() depends on ordering of input even if RNG is given
> ---------------------------------------------------------------------------------
>
> Key: MATH-1533
> URL: https://issues.apache.org/jira/browse/MATH-1533
> Project: Commons Math
> Issue Type: Wish
> Affects Versions: 3.6.1
> Environment: Windows 10, Java 8
> Reporter: WFR
> Priority: Minor
>
> When constructing an EnumeratedDistribution with given RNG, the output of samples depends on the ordering of the input:
> {code:java}
> EnumeratedDistribution<Integer> dis1 = new EnumeratedDistribution<>(
> new Well19937c(42),
> new ArrayList<>(Arrays.asList(new Pair<>(1, 0.3), new Pair<>(2, 0.7)))
> );
> EnumeratedDistribution<Integer> dis2 = new EnumeratedDistribution<>(
> new Well19937c(42),
> new ArrayList<>(Arrays.asList(new Pair<>(2, 0.7), new Pair<>(1, 0.3)))
> );
> System.out.println(Arrays.toString(dis1.sample(2))); // Yields [2, 1]
> System.out.println(Arrays.toString(dis2.sample(2))); // Yields [2, 2]
> {code}
> I would expect the output to be deterministic in this case, given that the RNG is fixed and that from the definition of enumerated distributions there is no reason for it to depend on the ordering of the input. Otherwise, a remark in the constructor's documentation would be useful.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)