[
https://issues.apache.org/jira/browse/MATH-1307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rostislav Krasny updated MATH-1307:
-----------------------------------
Comment: was deleted
(was: One comment about this code in the attached java file:
{code:java} /** {@inheritDoc} */
@Override
public boolean nextBoolean() {
return (nextInt() >>> 31) != 0;
}{code}
I think {{(nextInt() >>> 31) != 0}} is better to be changed to {{(nextInt() &
1) == 1}}, i.e. instead of checking the most significant bit (sign bit) to
check the least significant bit (parity bit). It's simpler and less likely to
get unevenness in results because of some characteristic of the algorithm used
in particular nextInt() implementation.)
> Create a base class for all RNGs
> --------------------------------
>
> Key: MATH-1307
> URL: https://issues.apache.org/jira/browse/MATH-1307
> Project: Commons Math
> Issue Type: Improvement
> Reporter: Gilles
> Assignee: Gilles
> Priority: Minor
> Labels: api, inheritance
> Fix For: 4.0
>
> Attachments: BaseRandomGenerator.java
>
>
> I proposed to create a base class which the existing abstract classes
> {{AbstractRandomGenerator}} and {{BitsStreamGenerator}} will extend.
> This would allow to define {{nextBytes(byte[])}} at the base class level.
> The code for that method is almost identical in the two hierarchies: they
> only differ in a call to either {{nextInt()}} or {{next(32)}} respectively;
> the latter is however the same as the former, in disguise, and is not subject
> to change given the type of return value.
> As a corollary, the new base class can be the unique place where to add
> utilities such as the one proposed in MATH-1306.
> *Update:* {{AbstractRandomGenerator}} and {{BitsStreamGenerator}} are both
> obsoleted by the class proposed in this report.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)