Skip to content

Commit c56f93c

Browse files
committed
Replace more usage of defaultNumericalPrecision
1 parent ce4c9f9 commit c56f93c

File tree

4 files changed

+27
-33
lines changed

4 files changed

+27
-33
lines changed

src/Math-Distributions/PMIncompleteBetaFunction.class.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ PMIncompleteBetaFunction >> evaluateFraction: aNumber [
2626
fraction setParameter: alpha1 second: alpha2 ].
2727
fraction setArgument: aNumber.
2828
^ (PMContinuedFraction server: fraction)
29-
desiredPrecision: PMFloatingPointMachine new defaultNumericalPrecision;
29+
desiredPrecision: Float defaultComparisonPrecision;
3030
evaluate
3131
]
3232

@@ -38,7 +38,7 @@ PMIncompleteBetaFunction >> evaluateInverseFraction: aNumber [
3838
inverseFraction setParameter: alpha2 second: alpha1 ].
3939
inverseFraction setArgument: 1 - aNumber.
4040
^ (PMContinuedFraction server: inverseFraction)
41-
desiredPrecision: PMFloatingPointMachine new defaultNumericalPrecision;
41+
desiredPrecision: Float defaultComparisonPrecision;
4242
evaluate
4343
]
4444

src/Math-Distributions/PMIncompleteGammaFunction.class.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ PMIncompleteGammaFunction >> evaluateFraction: aNumber [
2424
fraction setParameter: alpha ].
2525
fraction setArgument: aNumber.
2626
^ (PMContinuedFraction server: fraction)
27-
desiredPrecision: PMFloatingPointMachine new defaultNumericalPrecision;
27+
desiredPrecision: Float defaultComparisonPrecision;
2828
evaluate
2929
]
3030

@@ -36,7 +36,7 @@ PMIncompleteGammaFunction >> evaluateSeries: aNumber [
3636
series setParameter: alpha ].
3737
series setArgument: aNumber.
3838
^ (PMInfiniteSeries server: series)
39-
desiredPrecision: PMFloatingPointMachine new defaultNumericalPrecision;
39+
desiredPrecision: Float defaultComparisonPrecision;
4040
evaluate
4141
]
4242

src/Math-Tests-Distributions/PMStatisticsBugs.class.st

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ PMStatisticsBugs >> testGammaDistribution [
180180

181181
| dist a |
182182
dist := PMGammaDistribution shape: 3.4 scale: 1.7.
183-
self assert: (dist average - (3.4 * 1.7)) abs < 0.000000001.
184-
self assert: (dist standardDeviation - (3.4 sqrt * 1.7)) abs < 0.000000001.
185-
self assert: ((dist value: 4.5) - 0.1446067652) abs < 0.000000001.
186-
self assert: ((dist distributionValue: 4.5) - 0.3982869736) abs < 0.000000001.
183+
self assert: dist average - (3.4 * 1.7) closeTo: 0.
184+
self assert: dist standardDeviation - (3.4 sqrt * 1.7) closeTo: 0.
185+
self assert: (dist value: 4.5) - 0.1446067652 closeTo: 0.
186+
self assert: (dist distributionValue: 4.5) - 0.3982869736 closeTo: 0.
187187

188188

189189
a := PMGammaDistribution shape: 2 scale: 1.

src/Math-Tests-Numerical/PMNumericalMethodsTestCase.class.st

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,18 @@ PMNumericalMethodsTestCase >> testErrorFunction [
102102

103103
{ #category : #estimation }
104104
PMNumericalMethodsTestCase >> testFTest [
105+
105106
| accC accMM confidenceLevel |
106107
accC := PMStatisticalMoments new.
107-
#(5.56 5.89 4.66 5.69 5.34 4.79 4.80 7.86 3.64 5.70)
108-
do: [ :x | accC accumulate: x ].
108+
#( 5.56 5.89 4.66 5.69 5.34 4.79 4.80 7.86 3.64 5.70 ) do: [ :x | accC accumulate: x ].
109109
accMM := PMStatisticalMoments new.
110-
#(7.48 6.75 3.77 5.71 7.25 4.73 6.23 5.60 5.94 4.58)
111-
do: [ :x | accMM accumulate: x ].
110+
#( 7.48 6.75 3.77 5.71 7.25 4.73 6.23 5.60 5.94 4.58 ) do: [ :x | accMM accumulate: x ].
112111
confidenceLevel := accC fConfidenceLevel: accMM.
113-
self assert: (accC average - 5.393) abs < 0.000000001.
114-
self
115-
assert: (accC standardDeviation - 1.0990809292) abs < 0.000000001.
116-
self assert: (accMM average - 5.804) abs < 0.000000001.
117-
self assert: (accMM standardDeviation - 1.19415428) abs < 0.000000001.
118-
self assert: (confidenceLevel - 79.8147614536) abs < 0.000000001
112+
self assert: accC average - 5.393 closeTo: 0.
113+
self assert: accC standardDeviation - 1.0990809292 closeTo: 0.
114+
self assert: accMM average - 5.804 closeTo: 0.
115+
self assert: accMM standardDeviation - 1.19415428 closeTo: 0.
116+
self assert: confidenceLevel - 79.8147614536 closeTo: 0
119117
]
120118

121119
{ #category : #statistics }
@@ -155,10 +153,8 @@ PMNumericalMethodsTestCase >> testIncompleteBetaFunction [
155153

156154
{ #category : #'iterative algorithms' }
157155
PMNumericalMethodsTestCase >> testIncompleteGammaFunction [
158-
| function |
159-
function := PMIncompleteGammaFunction shape: 2.
160-
self
161-
assert: ((function value: 2) - 0.59399414981) abs < 0.00000000001
156+
157+
self assert: ((PMIncompleteGammaFunction shape: 2) value: 2) - 0.59399414981 closeTo: 0
162158
]
163159

164160
{ #category : #'iterative algorithms' }
@@ -819,7 +815,7 @@ PMNumericalMethodsTestCase >> testOptimizeOneDimension [
819815
finder := PMOneVariableFunctionOptimizer maximizingFunction: distr.
820816
finder desiredPrecision: 1.0e-6.
821817
maximum := finder evaluate.
822-
self assert: (maximum - 5) abs < 1.0e-6.
818+
self assert: maximum - 5 closeTo: 0.
823819
self assert: finder precision < 1.0e-6
824820
]
825821

@@ -950,20 +946,18 @@ PMNumericalMethodsTestCase >> testSymmetricMatrixAdd3 [
950946

951947
{ #category : #estimation }
952948
PMNumericalMethodsTestCase >> testTTest [
949+
953950
| accC accMM confidenceLevel |
954951
accC := PMStatisticalMoments new.
955-
#(5.56 5.89 4.66 5.69 5.34 4.79 4.80 7.86 3.64 5.70)
956-
do: [ :x | accC accumulate: x ].
952+
#( 5.56 5.89 4.66 5.69 5.34 4.79 4.80 7.86 3.64 5.70 ) do: [ :x | accC accumulate: x ].
957953
accMM := PMStatisticalMoments new.
958-
#(7.48 6.75 3.77 5.71 7.25 4.73 6.23 5.60 5.94 4.58)
959-
do: [ :x | accMM accumulate: x ].
954+
#( 7.48 6.75 3.77 5.71 7.25 4.73 6.23 5.60 5.94 4.58 ) do: [ :x | accMM accumulate: x ].
960955
confidenceLevel := accC tConfidenceLevel: accMM.
961-
self assert: (accC average - 5.393) abs < 0.000000001.
962-
self
963-
assert: (accC standardDeviation - 1.0990809292) abs < 0.000000001.
964-
self assert: (accMM average - 5.804) abs < 0.000000001.
965-
self assert: (accMM standardDeviation - 1.19415428) abs < 0.000000001.
966-
self assert: (confidenceLevel - 56.6320739989) abs < 0.000000001
956+
self assert: accC average - 5.393 closeTo: 0.
957+
self assert: accC standardDeviation - 1.0990809292 closeTo: 0.
958+
self assert: accMM average - 5.804 closeTo: 0.
959+
self assert: accMM standardDeviation - 1.19415428 closeTo: 0.
960+
self assert: confidenceLevel - 56.6320739989 closeTo: 0
967961
]
968962

969963
{ #category : #'linear algebra' }

0 commit comments

Comments
 (0)