• 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

38.0
/src/Math-Distributions/PMLogNormalDistribution.class.st
1
Class {
2
        #name : #PMLogNormalDistribution,
3
        #superclass : #PMProbabilityDensity,
4
        #instVars : [
5
                'normalDistribution'
6
        ],
7
        #category : #'Math-Distributions-Normal'
8
}
9

10
{ #category : #information }
11
PMLogNormalDistribution class >> distributionName [
×
12
        ^ 'Log normal distribution'
×
13
]
×
14

15
{ #category : #creation }
16
PMLogNormalDistribution class >> fromHistogram: aHistogram [
×
17
                "Create an instance of the receiver with parameters estimated from the
×
18
                  given histogram using best guesses. This method can be used to
×
19
                  find the initial values for a fit."
×
20
        | average variance sigma2 |
×
21
        aHistogram minimum < 0
×
22
                ifTrue: [ ^nil].
×
23
        average := aHistogram average.
×
24
        average > 0
×
25
                ifFalse: [ ^nil].
×
26
        variance := aHistogram variance.
×
27
        sigma2 := ( variance / average squared + 1) ln.
×
28
        sigma2 > 0
×
29
                ifFalse: [ ^nil].
×
30
        ^self new: ( average ln - (sigma2 * 0.5)) sigma: sigma2 sqrt
×
31
]
×
32

33
{ #category : #creation }
34
PMLogNormalDistribution class >> new [
3✔
35
                "Create a new instance of the receiver with mu=0 and sigma=1."
3✔
36
        ^self new: 0 sigma: 1
3✔
37
]
3✔
38

39
{ #category : #creation }
40
PMLogNormalDistribution class >> new: aNumber1 sigma: aNumber2 [
3✔
41
                "Create a new instance of the receiver with given mu and sigma."
3✔
42
        ^super new initialize: aNumber1 sigma: aNumber2
3✔
43
]
3✔
44

45
{ #category : #information }
46
PMLogNormalDistribution >> acceptanceBetween: aNumber1 and: aNumber2 [
3✔
47
                "Answers the probability of observing a random variable distributed according to
3✔
48
                 the receiver with a value larger than aNumber 1 and lower than or equal to aNumber2."
3✔
49
        ^( PMRombergIntegrator function: [:x| self value:x] from: aNumber1 to: aNumber2) evaluate
3✔
50
]
3✔
51

52
{ #category : #information }
53
PMLogNormalDistribution >> average [
3✔
54
                "Answer the average of the receiver."
3✔
55
        ^( normalDistribution variance*0.5 + normalDistribution average) exp
3✔
56
]
3✔
57

58
{ #category : #transformation }
59
PMLogNormalDistribution >> changeParametersBy: aVector [
×
60
                "Modify the parameters of the receiver by aVector."
×
61
        normalDistribution changeParametersBy: aVector
×
62
]
×
63

64
{ #category : #information }
65
PMLogNormalDistribution >> distributionValue: aNumber [
3✔
66
                "Answers the probability of observing a random variable distributed according to
3✔
67
                 the receiver with a value lower than or equal to aNumber.
3✔
68
                 This general purpose routine uses numerical integration."
3✔
69
        ^( PMRombergIntegrator function: [:x| self value:x] from: self lowestValue to: aNumber) evaluate
3✔
70
]
3✔
71

72
{ #category : #information }
73
PMLogNormalDistribution >> fourthCentralMoment [
×
74
                "Private"
×
75
        | y x |
×
76
        y := normalDistribution average exp.
×
77
        x := normalDistribution variance exp.
×
78
        ^( y squared squared) * ( x squared)
×
79
                * ( ( ( x squared * x - 4) * ( x squared) + 6) * x - 3)
×
80
]
×
81

82
{ #category : #initialization }
83
PMLogNormalDistribution >> initialize: aNumber1 sigma: aNumber2 [
3✔
84
                "Private - Defines the parameters of the receiver."
3✔
85
        normalDistribution := PMNormalDistribution new: aNumber1 sigma: aNumber2.
3✔
86
        ^self
3✔
87
]
3✔
88

89
{ #category : #information }
90
PMLogNormalDistribution >> kurtosis [
×
91
                "Answer the variance of the receiver."
×
92
        | x |
×
93
        x := normalDistribution variance exp.
×
94
        ^( ( x + 2) * x + 3) * ( x squared) - 6
×
95
]
×
96

97
{ #category : #information }
98
PMLogNormalDistribution >> lowestValue [
3✔
99
        ^0
3✔
100
]
3✔
101

102
{ #category : #information }
103
PMLogNormalDistribution >> parameters [
×
104
        ^normalDistribution parameters
×
105
]
×
106

107
{ #category : #information }
108
PMLogNormalDistribution >> random [
×
109
                "Answer a random number distributed accroding to the receiver."
×
110
        ^normalDistribution random exp
×
111
]
×
112

113
{ #category : #information }
114
PMLogNormalDistribution >> skewness [
×
115
                "Answer the variance of the receiver."
×
116
        | x |
×
117
        x := normalDistribution variance exp.
×
118
        ^(x - 1) sqrt * (x + 2)
×
119
]
×
120

121
{ #category : #information }
122
PMLogNormalDistribution >> thirdCentralMoment [
×
123
                "Private"
×
124
        | y x |
×
125
        y := normalDistribution average exp.
×
126
        x := normalDistribution variance exp.
×
127
        ^( y squared * y) * ( x raisedTo: (3/2))
×
128
                * ( ( x squared negated + 3) * x - 2)
×
129
]
×
130

131
{ #category : #information }
132
PMLogNormalDistribution >> value: aNumber [
3✔
133
                "Answers the probability that a random variable distributed according to the receiver
3✔
134
                 gives a value between aNumber and aNumber + espilon (infinitesimal interval)."
3✔
135
        ^aNumber > 0
3✔
136
                ifTrue: [ ( normalDistribution value: aNumber ln) / aNumber]
3✔
137
                ifFalse:[ 0]
3✔
138
]
3✔
139

140
{ #category : #information }
141
PMLogNormalDistribution >> variance [
×
142
                "Answer the variance of the receiver."
×
143
        ^( normalDistribution average * 2 + normalDistribution variance) exp * ( normalDistribution variance exp - 1)
×
144
]
×
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

© 2025 Coveralls, Inc