• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PolyMathOrg / PolyMath / 4385132063

pending completion
4385132063

push

github

GitHub
Merge pull request #316 from jecisc/divers-cleanings

2977 of 2977 new or added lines in 214 files covered. (100.0%)

19725 of 24212 relevant lines covered (81.47%)

2.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.27
/src/Math-Numerical/PMMaximumLikelihoodHistogramFit.class.st
1
Class {
2
        #name : #PMMaximumLikelihoodHistogramFit,
3
        #superclass : #PMLeastSquareFit,
4
        #instVars : [
5
                'count',
6
                'countVariance'
7
        ],
8
        #category : #'Math-Numerical'
9
}
10

11
{ #category : #operation }
12
PMMaximumLikelihoodHistogramFit >> accumulate: aWeightedPoint [
3✔
13
                "Private"
3✔
14
        | f g temp inverseProbability|
3✔
15
        f := result valueAndGradient: aWeightedPoint xValue.
3✔
16
        g := f last copyFrom: 1 to: ( f last size - 1).
3✔
17
        f := f first.
3✔
18
        f = 0 ifTrue: [ ^nil].
3✔
19
        inverseProbability := 1 / f.
3✔
20
        temp := aWeightedPoint yValue * inverseProbability.
3✔
21
        constants accumulate: g * temp.
3✔
22
        temp := temp * inverseProbability.
3✔
23
        1 to: g size do:
3✔
24
                [ :k |
3✔
25
                  ( equations at: k) accumulate: g * ( ( g at: k) * temp).
3✔
26
                ]
3✔
27
]
3✔
28

29
{ #category : #operation }
30
PMMaximumLikelihoodHistogramFit >> computeChanges [
3✔
31
                "Private"
3✔
32
        ^super computeChanges copyWith: 0
3✔
33
]
3✔
34

35
{ #category : #operation }
36
PMMaximumLikelihoodHistogramFit >> computeNormalization [
3✔
37
        "Private"
3✔
38

3✔
39
        | numerator denominator temp |
3✔
40
        numerator := 0.
3✔
41
        denominator := 0.
3✔
42
        dataHolder pointsAndErrorsDo:
3✔
43
                        [:each |
3✔
44
                        temp := result value: each xValue.
3✔
45
                        temp = 0
3✔
46
                                ifFalse:
3✔
47
                                        [numerator := numerator + (each yValue squared / temp).
3✔
48
                                        denominator := denominator + temp]].
3✔
49
        count := ( numerator / denominator) sqrt.
3✔
50
        countVariance := numerator / ( 4 * count)
3✔
51
]
3✔
52

53
{ #category : #operation }
54
PMMaximumLikelihoodHistogramFit >> finalizeIterations [
3✔
55
        "Compute the normalization factor."
3✔
56

3✔
57
        self computeNormalization.
3✔
58
        result setCount: count.
3✔
59
        super finalizeIterations
3✔
60
]
3✔
61

62
{ #category : #information }
63
PMMaximumLikelihoodHistogramFit >> fitType [
×
64
        ^ 'Maximum likelihood fit'
×
65
]
×
66

67
{ #category : #operation }
68
PMMaximumLikelihoodHistogramFit >> initializeIterations [
3✔
69
        result setCount: 1.
3✔
70
        count := dataHolder totalCount.
3✔
71
        super initializeIterations
3✔
72
]
3✔
73

74
{ #category : #information }
75
PMMaximumLikelihoodHistogramFit >> normalization [
×
76
        ^ count
×
77
]
×
78

79
{ #category : #information }
80
PMMaximumLikelihoodHistogramFit >> normalizationError [
×
81
        ^countVariance sqrt
×
82
]
×
83

84
{ #category : #information }
85
PMMaximumLikelihoodHistogramFit >> numberOfFreeParameters [
×
86
                "Private"
×
87
        ^super numberOfParameters
×
88
]
×
89

90
{ #category : #information }
91
PMMaximumLikelihoodHistogramFit >> numberOfParameters [
3✔
92
                "Private"
3✔
93
        ^super numberOfParameters - 1
3✔
94
]
3✔
95

96
{ #category : #information }
97
PMMaximumLikelihoodHistogramFit >> valueAndError: aNumber [
×
98

×
99
        | valueGradient gradient gVar |
×
100
        valueGradient := result valueAndGradient: aNumber.
×
101
        gradient := valueGradient last copyFrom: 1 to: valueGradient last size - 1.
×
102
        gVar := gradient * (self errorMatrix * gradient) / count.
×
103
        ^Array with: valueGradient first
×
104
                with: ((valueGradient first / count) squared * countVariance + gVar) sqrt
×
105
]
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc