commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-1341) "RandomDataGenerator" is brittle
Date Sat, 19 Mar 2016 23:25:33 GMT

    [ https://issues.apache.org/jira/browse/MATH-1341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15203006#comment-15203006
] 

Gilles commented on MATH-1341:
------------------------------

Another performance hit: For each sampling, a new distribution object is created.
This will be compounded with the new sampling API (MATH-1158) where a {{Sampler}} object will
also be created.

If a user needs sampling from a distribution, is there any advantage to use {{RandomDataGenerator}}
(over instantiating the appropriate {{Sampler}} instance)?
Even if an application might have some use of the syntactic sugar which this class provides,
is there any advantage for CM to provide an alternative sampling API that is not efficient?


> "RandomDataGenerator" is brittle
> --------------------------------
>
>                 Key: MATH-1341
>                 URL: https://issues.apache.org/jira/browse/MATH-1341
>             Project: Commons Math
>          Issue Type: Bug
>            Reporter: Gilles
>            Priority: Minor
>              Labels: API, cleanup, deprecation, thread-safety
>             Fix For: 4.0
>
>
> Class {{RandomDataGenerator}} can easily be misused as it advertizes a method to access
its internal RNG (which is _not_ thread-safe).
> The class is also a mixed bag of "data generators" that are either "secure" or not.
> Moreover it uses the "lazy initialization" pattern (for the RNG instance) solely because
of this duality; otherwise users that need one or the other form of data generation will obviously
always use the RNG since all data generation methods need it.
> This entails also a performance hit (albeit tiny) as each call checks whether the RNG
has been initialized already.
> The clean solution would be to separate the two types of data generation (secure vs not)
into different classes.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message