@@ -42,17 +42,17 @@ public class TestModels {
4242 */
4343 public static class TestModel {
4444
45- private int buckets ;
46- private int featureCount ;
45+ private final int buckets ;
46+ private final int featureCount ;
4747 final double [][] observations ;
48- private Statistics expectedStatistics ;
49- private double [] expectedSlopeCoefficients ;
48+ private final Statistics expectedStatistics ;
49+ private final double [] expectedSlopeCoefficients ;
5050 private StatsSampling statsSampling ;
5151 private DerivationEquation equation ;
5252
5353 public TestModel (final int buckets , final int featureCount , final double [][] observations ,
54- double [] expectedSlopeCoefficients ,
55- Statistics statistics ) {
54+ final double [] expectedSlopeCoefficients ,
55+ final Statistics statistics ) {
5656 this .buckets = buckets ;
5757 this .featureCount = featureCount ;
5858 this .observations = observations ;
@@ -63,65 +63,66 @@ public TestModel(final int buckets, final int featureCount, final double[][] obs
6363 }
6464
6565 private StatsSampling <?> createSampling () {
66- ExactModelSamplingFactory f = new ExactModelSamplingFactory ();
67- ExactSamplingContext samplingContext = f .createContext (featureCount );
68- return new StatsSamplingProxy <> (samplingContext , f
66+ final ExactModelSamplingFactory f = new ExactModelSamplingFactory ();
67+ final ExactSamplingContext samplingContext = f .createContext (this . featureCount );
68+ return new StatsSamplingProxy (samplingContext , f
6969 .createResponseVarianceTermSampling (samplingContext ), f
7070 .createCoefficientLinearTermSampling (samplingContext ), f
7171 .createCoefficientSquareTermSampling (samplingContext ));
7272 }
7373
74- @ SuppressWarnings ("unchecked" )
7574 private void sample () {
76- List <StatsSampling <?>> bucketSamplings = new ArrayList <>(buckets );
77- for (int i = 0 ; i < buckets ; i ++) {
75+ final List <StatsSampling <?>> bucketSamplings = new ArrayList <>(this . buckets );
76+ for (int i = 0 ; i < this . buckets ; i ++) {
7877 bucketSamplings .add (createSampling ());
7978 }
8079 int b = 0 ;
81- for (int i = 0 ; i < observations .length ; i ++) {
82- bucketSamplings .get (b ).sample (observations [i ], observations [i ][observations [i ].length - 1 ]);
80+ for (int i = 0 ; i < this .observations .length ; i ++) {
81+ bucketSamplings .get (b ).sample (
82+ this .observations [i ], this .observations [i ][this .observations [i ].length - 1 ]);
8383 b ++;
84- if (b >= buckets ) {
84+ if (b >= this . buckets ) {
8585 b = 0 ;
8686 }
8787 }
88- statsSampling = createSampling ();
89- for (int i = 0 ; i < buckets ; i ++) {
90- statsSampling .merge (bucketSamplings .get (i ));
88+ this . statsSampling = createSampling ();
89+ for (int i = 0 ; i < this . buckets ; i ++) {
90+ this . statsSampling .merge (bucketSamplings .get (i ));
9191 }
92- equation = new DerivationEquationBuilder ()
93- .buildDerivationEquation (statsSampling );
92+ this . equation = new DerivationEquationBuilder ()
93+ .buildDerivationEquation (this . statsSampling );
9494 }
9595
9696 public double [] getExpectedSlopeCoefficients () {
97- return expectedSlopeCoefficients ;
97+ return this . expectedSlopeCoefficients ;
9898 }
9999
100100 public Statistics getExpectedStatistics () {
101- return expectedStatistics ;
101+ return this . expectedStatistics ;
102102 }
103103
104104 public DerivationEquation getEquation () {
105- return equation ;
105+ return this . equation ;
106106 }
107107
108108 public StatsModel evaluateModel () {
109- SlopeCoefficients coefficients = new CommonsMathSolver ().solveCoefficients (equation );
110- return new StatsModel (statsSampling , coefficients );
109+ final SlopeCoefficients coefficients = new CommonsMathSolver ().solveCoefficients (
110+ this .equation );
111+ return new StatsModel (this .statsSampling , coefficients );
111112 }
112113
113- public void assertCoefficients (double [] givenCoefficients , double delta ) {
114+ public void assertCoefficients (final double [] givenCoefficients , final double delta ) {
114115 assertEquals ("Count of evaluated coefficients not equal" ,
115- expectedSlopeCoefficients .length , givenCoefficients .length );
116- for (int i = 0 ; i < expectedSlopeCoefficients .length ; i ++) {
116+ this . expectedSlopeCoefficients .length , givenCoefficients .length );
117+ for (int i = 0 ; i < this . expectedSlopeCoefficients .length ; i ++) {
117118 assertEquals ("Evaluated coefficient " + i + " not eqal" ,
118- expectedSlopeCoefficients [i ], givenCoefficients [i ], delta );
119+ this . expectedSlopeCoefficients [i ], givenCoefficients [i ], delta );
119120 }
120121 }
121122
122123 public void assertStatistics (final Statistics statistics ) {
123- assertEquals ("RSS not equal" , expectedStatistics .getRss (), statistics .getRss (), 0.0001d );
124- assertEquals ("MSE not equal" , expectedStatistics .getMse (), statistics .getMse (), 0.0001d );
124+ assertEquals ("RSS not equal" , this . expectedStatistics .getRss (), statistics .getRss (), 0.0001d );
125+ assertEquals ("MSE not equal" , this . expectedStatistics .getMse (), statistics .getMse (), 0.0001d );
125126 }
126127 }
127128
0 commit comments