• 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

77.55
/src/Math-Distributions/PMCongruentialRandomNumberGenerator.class.st
1
Class {
2
        #name : #PMCongruentialRandomNumberGenerator,
3
        #superclass : #Object,
4
        #instVars : [
5
                'constant',
6
                'modulus',
7
                'multiplicator',
8
                'seed'
9
        ],
10
        #classVars : [
11
                'UniqueInstance'
12
        ],
13
        #category : #'Math-Distributions'
14
}
15

16
{ #category : #creation }
17
PMCongruentialRandomNumberGenerator class >> constant: aNumber1 multiplicator: aNumber2 modulus: aNumber3 [
×
18

×
19
        ^super new
×
20
                initialize: aNumber1
×
21
                multiplicator: aNumber2
×
22
                modulus: aNumber3
×
23
]
×
24

25
{ #category : #creation }
26
PMCongruentialRandomNumberGenerator class >> new [
3✔
27
        "Create a new instance of the receiver with D. Knuth's constants."
3✔
28

3✔
29
        UniqueInstance ifNil: [
3✔
30
                UniqueInstance := super new initialize.
3✔
31
                UniqueInstance setSeed: 1 ].
3✔
32
        ^ UniqueInstance
3✔
33
]
3✔
34

35
{ #category : #creation }
36
PMCongruentialRandomNumberGenerator class >> seed: aNumber [
3✔
37
        "Create a new instance of the receiver with given seed using D. Knuth's constants."
3✔
38
        ^ super new initialize; setSeed: aNumber; yourself
3✔
39
]
3✔
40

41
{ #category : #information }
42
PMCongruentialRandomNumberGenerator >> floatValue [
3✔
43
        "Answer the next pseudo-random value between 0 and 1."
3✔
44
        ^self value asFloat / modulus
3✔
45
]
3✔
46

47
{ #category : #initialization }
48
PMCongruentialRandomNumberGenerator >> initialize [
3✔
49

3✔
50
        super initialize.
3✔
51

3✔
52
        self initialize: 2718281829.0 multiplicator: 3141592653.0 modulus: 4294967296.0
3✔
53
]
3✔
54

55
{ #category : #initialization }
56
PMCongruentialRandomNumberGenerator >> initialize: aNumber1 multiplicator: aNumber2 modulus: aNumber3 [
3✔
57

3✔
58
        constant := aNumber1.
3✔
59
        modulus := aNumber2.
3✔
60
        multiplicator := aNumber3.
3✔
61
        self setSeed: 1
3✔
62
]
3✔
63

64
{ #category : #information }
65
PMCongruentialRandomNumberGenerator >> integerValue: anInteger [
×
66
        "Answer a random integer between 0 and the anInteger."
×
67
        ^( self value  \\ ( anInteger * 1000)) // 1000
×
68
]
×
69

70
{ #category : #transformation }
71
PMCongruentialRandomNumberGenerator >> setSeed: aNumber [
3✔
72
        "Set the seed of the receiver to aNumber."
3✔
73
        seed := aNumber
3✔
74
]
3✔
75

76
{ #category : #information }
77
PMCongruentialRandomNumberGenerator >> value [
3✔
78
        "Answer the next pseudo-random value."
3✔
79
        seed := ( seed * multiplicator + constant) \\ modulus.
3✔
80
        ^seed
3✔
81
]
3✔
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