• 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

31.65
/src/Math-Distributions/PMUniformDistribution.class.st
1
Class {
2
        #name : #PMUniformDistribution,
3
        #superclass : #PMProbabilityDensity,
4
        #instVars : [
5
                'lowLimit',
6
                'highLimit'
7
        ],
8
        #category : #'Math-Distributions'
9
}
10

11
{ #category : #public }
12
PMUniformDistribution class >> distributionName [
×
13
        ^'Uniform distribution'
×
14
]
×
15

16
{ #category : #public }
17
PMUniformDistribution class >> from: aNumber1 to: aNumber2 [
3✔
18
                "Create a new instance of the receiver with given limits."
3✔
19
        ^super new initialize: aNumber1 to: aNumber2
3✔
20
]
3✔
21

22
{ #category : #public }
23
PMUniformDistribution class >> fromHistogram: aHistogram [
×
24
                "Create an instance of the receiver with parameters estimated from the
×
25
                  given histogram using best guesses. This method can be used to
×
26
                  find the initial values for a fit.
×
27
                 Default returns nil (must be implemented by subclass)."
×
28
        | b c|
×
29
        b := aHistogram standardDeviation * 1.73205080756888 "12 sqrt / 2".
×
30
        b = 0
×
31
                ifTrue: [ ^nil].
×
32
        c := aHistogram average.
×
33
        ^self from: ( c - b) to: ( c + b)
×
34
]
×
35

36
{ #category : #public }
37
PMUniformDistribution class >> new [
×
38
                "Create a new instance of the receiver with limits 0 and 1."
×
39
        ^self from: 0 to: 1
×
40
]
×
41

42
{ #category : #information }
43
PMUniformDistribution >> average [
×
44
                "Answer the average of the receiver."
×
45
        ^( highLimit + lowLimit) / 2
×
46
]
×
47

48
{ #category : #transformation }
49
PMUniformDistribution >> changeParametersBy: aVector [
×
50
                "Modify the parameters of the receiver by aVector."
×
51
        lowLimit := lowLimit + ( aVector at: 1).
×
52
        highLimit := highLimit + ( aVector at: 2)
×
53
]
×
54

55
{ #category : #information }
56
PMUniformDistribution >> distributionValue: aNumber [
3✔
57
                "Answers the probability of observing a random variable distributed according to
3✔
58
                 the receiver with a value lower than or equal to aNumber."
3✔
59
        aNumber < lowLimit
3✔
60
                ifTrue: [ ^0].
3✔
61
        ^aNumber < highLimit
3✔
62
                ifTrue: [ (aNumber - lowLimit) / ( highLimit - lowLimit)]
3✔
63
                ifFalse:[ 1]
3✔
64
]
3✔
65

66
{ #category : #initialization }
67
PMUniformDistribution >> initialize: aNumber1 to: aNumber2 [
3✔
68
                "Private - Defines the limits of the receiver."
3✔
69
        aNumber1 < aNumber2
3✔
70
                ifFalse: [ self error: 'Illegal distribution parameters'].
3✔
71
        lowLimit := aNumber1.
3✔
72
        highLimit := aNumber2.
3✔
73
        ^self
3✔
74
]
3✔
75

76
{ #category : #information }
77
PMUniformDistribution >> kurtosis [
×
78
                "Answer the kurtosis of the receiver."
×
79
        ^-12 / 10
×
80
]
×
81

82
{ #category : #information }
83
PMUniformDistribution >> parameters [
×
84
        ^Array with: lowLimit with: highLimit
×
85
]
×
86

87
{ #category : #information }
88
PMUniformDistribution >> privateInverseDistributionValue: aNumber [
3✔
89
                "Private"
3✔
90
        ^(highLimit - lowLimit) * aNumber + lowLimit
3✔
91
]
3✔
92

93
{ #category : #information }
94
PMUniformDistribution >> skewness [
×
95
                "Answer the skewness of the receiver."
×
96
        ^0
×
97
]
×
98

99
{ #category : #information }
100
PMUniformDistribution >> standardDeviation [
×
101
                "Answer the standard deviation of the receiver."
×
102
        ^( highLimit - lowLimit) / 3.46410161513775 "12 sqrt"
×
103
]
×
104

105
{ #category : #information }
106
PMUniformDistribution >> value: aNumber [
×
107
                "Answers the probability that a random variable distributed according to the receiver
×
108
                 gives a value between aNumber and aNumber + espilon (infinitesimal interval)."
×
109
        ^( aNumber between: lowLimit and: highLimit)
×
110
                ifTrue: [ 1/( highLimit - lowLimit)]
×
111
                ifFalse:[ 0]
×
112
]
×
113

114
{ #category : #information }
115
PMUniformDistribution >> variance [
×
116
                "Answer the variance of the receiver."
×
117
        ^( highLimit - lowLimit) squared / 12
×
118
]
×
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