You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Rob Tompkins (JIRA)" <ji...@apache.org> on 2016/03/22 16:06:25 UTC

[jira] [Comment Edited] (MATH-1338) Does "EmpiricalDistribution" use "RandomDataGenerator"?

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

Rob Tompkins edited comment on MATH-1338 at 3/22/16 3:06 PM:
-------------------------------------------------------------

Seems like the thing to do here is to {{@Depricated}} to the method no longer needed and have it call the desired method for the time being. Does that seem correct?

Also it seems like the method, of the two in question from your comment, to deprecate is {{reSeed(long seed)}} simply because it isn't inherited and is from an earlier version of the API. 


was (Author: chtompki):
Seems like the thing to do here is to @Depricated to the method no longer needed and have it call the desired method for the time being. Does that seem correct?

> Does "EmpiricalDistribution" use "RandomDataGenerator"?
> -------------------------------------------------------
>
>                 Key: MATH-1338
>                 URL: https://issues.apache.org/jira/browse/MATH-1338
>             Project: Commons Math
>          Issue Type: Bug
>            Reporter: Gilles
>            Priority: Blocker
>              Labels: api, cleanup, exception
>             Fix For: 4.0
>
>
> The class {{EmpiricalDistribution}} (in package "o.a.c.m.random") holds an instance field ("randomData") of type {{RandomDataGenerator}}.
> The documentation of this field indicates that it is only used for sampling, and indeed the field is only accessed in order to fetch the RNG object stored in it. 
> It is unclear why {{RandomDataGenerator}} was needed to hold a RNG since the same RNG could have been (in the current design) readily available in the base class.
> Sampling is performed in method {{getNextValue()}} (which in turn calls {{sample()}} in the parent class).
> {{getNextValue()}} performs a precondition check before calling {{sample()}} and raises a CM specific {{MathIllegalStateException}}; but the inherited {{sample()}} method can be still called directly on the instance, and in that case, if the (same) condition is not fulfilled, a standard {{NullPointerException}} will be thrown instead.
> In line with MATH-1158, the sampling functionality should be accessed through the {{RealDistribution.Sampler}} interface, and {{getNextValue()}} is to be removed as it duplicates the common API (i.e. the {{sample()}} method).
> Since the RNG is then passed to the {{createSampler}} factory method, the "randomData" field becomes obsolete.



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