@@ -4,38 +4,52 @@ Class {
44 #instVars : [
55 ' dataServer'
66 ],
7- #category : ' Math-Tests-Clustering'
7+ #category : # ' Math-Tests-Clustering'
88}
99
1010{ #category : #utils }
1111PMClusterFinderTest >> accumulateAround: aVector size: aNumber into: aCollection [
1212 " Private - Generate a random point around the given center and insert it into the collection.
1313 aNumber is the sigma for the distance to the center"
1414
15- | r phi psi localVector |
15+ | random r phi psi localVector |
16+ random := Random new .
17+
1618 r := (PMNormalDistribution new : 0 sigma: aNumber) random.
17- phi := Float pi random.
18- psi := Float pi random.
19+
20+ phi := random nextBetween: 0 and : Float pi.
21+ psi := random nextBetween: 0 and : Float pi.
22+
1923 localVector := PMVector new : 3 .
20- localVector at: 1 put: ( phi sin * psi sin * r );
21- at: 2 put: ( phi cos * psi sin * r );
22- at: 3 put: ( psi cos * r ).
24+ localVector
25+ at: 1 put: (phi sin * psi sin * r);
26+ at: 2 put: (phi cos * psi sin * r);
27+ at: 3 put: (psi cos * r).
28+
2329 aCollection add: (localVector + aVector).
2430]
2531
2632{ #category : #utils }
2733PMClusterFinderTest >> generatedPoints: anInteger [
2834 " Private - Generate random points into aCollection. 3 clusters are used"
29- | centers results |
30- centers := Array new : 3 .
31- centers at: 1 put: #( 200 200 200) asPMVector;
32- at: 2 put: #(-200 200 200) asPMVector;
33- at: 3 put: #( 200 200 -200) asPMVector.
35+ | centers results random randomNumber |
36+
37+ centers := {
38+ #( 200 200 200) asPMVector .
39+ #(-200 200 200) asPMVector .
40+ #( 200 200 -200) asPMVector }.
41+
3442 results := OrderedCollection new .
3543 PMMitchellMooreGenerator reset: 6 .
36- " make tests non-random to make sure that they will not fail on the integrator server."
37- anInteger timesRepeat: [ self accumulateAround: ( centers at: (3 random + 1 )) size: 1 into: results ].
38- ^ results
44+
45+ " make tests non-random to make sure that they will not fail on the integrator server."
46+ random := Random new .
47+
48+ anInteger timesRepeat: [
49+ randomNumber := random nextIntegerBetween: 1 and : 3 .
50+ self accumulateAround: (centers at: randomNumber) size: 1 into: results ].
51+
52+ ^ results
3953]
4054
4155{ #category : #setUp }
0 commit comments