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

PolyMathOrg / PolyMath / 23651818384

27 Mar 2026 02:41PM UTC coverage: 81.274% (-0.4%) from 81.638%
23651818384

push

github

web-flow
Merge pull request #333 from DurieuxPol/fix/redTests

Fixed remaining red tests

57 of 88 new or added lines in 9 files covered. (64.77%)

50 existing lines in 4 files now uncovered.

19674 of 24207 relevant lines covered (81.27%)

3.25 hits per line

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

30.67
/src/Math-FunctionFit/PMFunctionFit.class.st
1
"
2
FunctionFit fits a function to some data. the data has to be a collection of points x@f(x). the fitting minimizes the squared error.
3
f:=[:x :a :b|a*x / (b+x)].
4
col:=(1 to: 20)collect: [:i|i@(f cull: i cull: 2 cull: 0.4) ].
5
fit:= FunctionFit function: f data: col .
6
fit evaluate . 
7
fit result parameters .   --->  #(1.9999999999999998 0.39999999999999863)
8
"
9
Class {
10
        #name : 'PMFunctionFit',
11
        #superclass : 'PMLeastSquareFit',
12
        #category : 'Math-FunctionFit',
13
        #package : 'Math-FunctionFit'
14
}
15

16
{ #category : 'creation' }
17
PMFunctionFit class >> function: aBlock data: aDataHolder [
4✔
18
^super points: aDataHolder  function:  (PMSimpleParameterFunction function: aBlock)
4✔
19
]
4✔
20

21
{ #category : 'creation' }
22
PMFunctionFit class >> histogram: aHistogram distributionClass: aProbabilityDensityFunctionClass [
×
23
^self shouldNotImplement
×
24
]
×
25

26
{ #category : 'creation' }
27
PMFunctionFit class >> points: aDataHolder function: aBlock [
×
28
^self shouldNotImplement
×
29
]
×
30

31
{ #category : 'operation' }
32
PMFunctionFit >> accumulate: aWeightedPoint [
4✔
33
        | f g |
4✔
34
        f := result valueAndGradient: aWeightedPoint xValue.
4✔
35
        g := f last.
4✔
36
        f := f first.
4✔
37
        f isNaN ifTrue:[^self].
4✔
38
        constants accumulate: g * ( ( aWeightedPoint yValue - f) * aWeightedPoint weight).
4✔
39
        1 to: g size do:
4✔
40
                [ :k |
4✔
41
                  ( equations at: k) accumulate: g * ( ( g at: k) * aWeightedPoint weight).
4✔
42
                ]
4✔
43
]
4✔
44

45
{ #category : 'operation' }
46
PMFunctionFit >> computeChanges [
4✔
47

4✔
48
        ^ [ super computeChanges ]
4✔
49
                  on: PMSingularMatrixError
4✔
50
                  do: [ :signal |
4✔
51
                          signal messageText: 'singular error matrix, set better parameters'.
4✔
52
                          signal pass ]
4✔
53
]
4✔
54

55
{ #category : 'information' }
56
PMFunctionFit >> computeChiSquare [
×
57
"does not make much sense to use in most cases, but then, the superclass has it and if its here, the calculation should be correct and the superclass's way does not work here eg because of the way DataHolder>>pointsAndErrorsDo: works"
×
58
        chiSquare := 0.
×
59
        degreeOfFreedom := self numberOfFreeParameters negated.
×
60
        dataHolder pointsAndErrorsDo:
×
61
                [ :each | |y|
×
62
                  y :=result value: each xValue .
×
63
                  (y closeTo: 0) ifFalse:
×
64
                          [chiSquare := (each yValue - y) squared / y abs +chiSquare  .
×
65
                          degreeOfFreedom := degreeOfFreedom + 1].
×
66
                ]
×
67
]
×
68

×
NEW
69
{ #category : 'initialization' }
×
70
PMFunctionFit >> initialize: aDataHolder data: aParametricFunction [
×
71
        (aDataHolder isCollection and: [aDataHolder allSatisfy: [:aPoint| aPoint isPoint]])
×
72
                        ifTrue:  [dataHolder:= aDataHolder as: PMDataHolder ]
×
73
                        ifFalse: [self error: 'DataHolder must be a Collection of Points'].
×
74
        dataHolder size < aParametricFunction parameterSize ifTrue:[self error: 'Problem is underdeterminated. aDataHolders size to small'].
×
75
        result := aParametricFunction.
×
76
        self finalizeIterations.
×
77
        ^self
×
78
]
×
79

×
NEW
80
{ #category : 'information' }
×
81
PMFunctionFit >> parameters [
×
82
^result parameters
×
83
]
×
84

×
NEW
85
{ #category : 'initialization' }
×
86
PMFunctionFit >> parameters: indexableCollection [
×
87

×
88
        indexableCollection do: [ :e |
×
89
                (e closeTo: 0.0) ifTrue: [
×
90
                        self error: 'parameters shouldnt be set to practically zero' ] ].
×
91
        result parameters: indexableCollection.
×
92
        self finalizeIterations
×
93
]
×
94

×
NEW
95
{ #category : 'printing' }
×
96
PMFunctionFit >> printOn: aStream [
×
97
        super printOn: aStream.
×
98
        aStream nextPutAll: ' for '.
×
99
        result printOn: aStream .
×
100
        aStream nextPutAll: ' with data of size: '; print: dataHolder size
×
101
]
×
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