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

Alex Herbert commented on STATISTICS-62:
----------------------------------------

{quote}Wrt the "cost" of object creation: Do we still (in recent JVMs) need to 
worry about it (for such small instances)?
{quote}
Given the resources used after the object is created no. It is just something 
to consider as an inefficient pattern to be avoided unless carefully considered.
{quote}Are we sure that any present or future implementation of a test is 
immutable? If not, won't it complicate the API that the default behaviour is to 
use a singleton (e.g. when the instance could be accessed from multiple 
threads)?
{quote}
The singleton is returned from a method. So if the class is in fact mutable 
then the method can return a new instance each time. Currently this is not an 
issue and a single instance can be returned. But the method 'withDefaults()' 
can return a new instance if required in the future.
{quote}Wrt "overengineering": IIUC, it's a trade-off (a single "complex" 
builder class that can easily accommodate new options vs each test class having 
to maintain its options handling), with small impact on the API (only having to 
call "get").
{quote}
I am not objecting to the Builder. I just do not see it as required for the 
present functionality, which is very closely matched to the functionality for 
the same tests in the mature libraries provided in R and SciPy stats. I prefer 
the non-builder API as all methods are documented in class and the test cannot 
be incorrectly built for its purpose (without the use of exceptions).

I have created a PR with the current code: [PR 
41|https://github.com/apache/commons-statistics/pull/41]

 

> Port o.a.c.math.stat.inference to a commons-statistics-inference module
> -----------------------------------------------------------------------
>
>                 Key: STATISTICS-62
>                 URL: https://issues.apache.org/jira/browse/STATISTICS-62
>             Project: Commons Statistics
>          Issue Type: New Feature
>          Components: inference
>    Affects Versions: 1.0
>            Reporter: Alex Herbert
>            Priority: Major
>
> The o.a.c.math4.legacy.stat.inference package contains:
>  
> {noformat}
> AlternativeHypothesis.java
> BinomialTest.java
> ChiSquareTest.java
> GTest.java
> InferenceTestUtils.java
> KolmogorovSmirnovTest.java
> MannWhitneyUTest.java
> OneWayAnova.java
> TTest.java
> WilcoxonSignedRankTest.java{noformat}
> The are few dependencies on other math packages. The notable exceptions are:
>  
> 1. KolmogorovSmirnovTest which requires matrix support. This is for 
> multiplication of a square matrix to support a matrix power function. This 
> uses a double matrix and the same code is duplicated for a BigFraction 
> matrix. Such code can be ported internally to support only the required 
> functions. It can also drop the defensive copy strategy used by Commons Math 
> in matrices to allow multiply in-place where appropriate for performance 
> gains.
> 2. OneWayAnova which collates the sum, sum of squares and count using 
> SummaryStatistics. This can be done using an internal class. It is possible 
> to call the test method using already computed SummaryStatistics. The method 
> that does this using the SummaryStatistics as part of the API can be dropped, 
> or supported using an interface that returns: getSum, getSumOfSquares, getN.
> All the inference Test classes have instance methods but no state. The 
> InferenceTestUtils is a static class that holds references to a singleton for 
> each class and provides static methods to pass through the underlying 
> instances.
> I suggest changing the test classes to have only static methods and dropping 
> InferenceTestUtils.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to