-
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathPMErrorAsParameterFunction.class.st
More file actions
71 lines (62 loc) · 1.98 KB
/
Copy pathPMErrorAsParameterFunction.class.st
File metadata and controls
71 lines (62 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"
ErrorAsParameterFunction is used internally by ErrorMinimizer. it is essentially a wrapper around an ErrorOfParameterFunction .
"
Class {
#name : #PMErrorAsParameterFunction,
#superclass : #PMSimpleParameterFunction,
#category : 'Math-FunctionFit'
}
{ #category : #accessing }
PMErrorAsParameterFunction >> changeParametersBy: aVector [
varArray :=varArray + aVector .
]
{ #category : #initialization }
PMErrorAsParameterFunction >> function: anErrorOfParameterFunction [
|d f size steps|
d :=anErrorOfParameterFunction data.
usedVars :=anErrorOfParameterFunction parameterSize .
self initializeVarArray: 1.
size:=d size sqrt ceiling .
steps:=d size // (usedVars +1).
size :=size +steps //2.
size := size min: steps.
steps :=d size //size -1.
steps <usedVars ifTrue:[self error: 'dataSize too small for the parameterSize'].
function := (0 to: steps)collect: [:i|
f:=anErrorOfParameterFunction copy.
f data: (d copyFrom:( i *size+1) to:( i=steps ifTrue: [d size] ifFalse: [(i+1) *size])).
f]
]
{ #category : #accessing }
PMErrorAsParameterFunction >> maxFunction [
"The number of data partitions used. The highest number that can be send to #value:"
^ function ifNil: [ 0 ] ifNotNil: [ :f | f size ]
]
{ #category : #accessing }
PMErrorAsParameterFunction >> parameters [
^varArray
]
{ #category : #accessing }
PMErrorAsParameterFunction >> parameters: indexableCollection [
^varArray :=indexableCollection copy.
]
{ #category : #printing }
PMErrorAsParameterFunction >> printOn: aStream [
aStream
nextPutAll: 'an ';
nextPutAll: self class name;
nextPutAll: '( function: ';
print: (function ifNil: [ nil ] ifNotNil: [ :f | f first ]);
nextPutAll: ' maxFunction: ';
print: self maxFunction.
varArray
ifNotNil: [ aStream
nextPutAll: ' parameters: ';
print: self parameters ].
aStream nextPut: $)
]
{ #category : #evaluating }
PMErrorAsParameterFunction >> value: aNumber [
"aNumber chooses the data partition. it can run from 1 to maxFunction."
^(function at: aNumber) value: varArray
]