Skip to content

Commit

Permalink
Moves standardDeviation: to correct morph
Browse files Browse the repository at this point in the history
  • Loading branch information
codeZeilen committed Jul 22, 2024
1 parent 709b03b commit fb5973d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ addValues
| times average count stdev |
times := values collect: [:v | v tracedValue].
count := times size.
average := times average.
average := times average roundTo: 0.01.
stdev := self standardDeviation: times.
self addMorphBack: ('{1} executions ({2} ms +/- {3})'
format: {count . average . stdev}) asText asMorph
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
helpers
standardDeviation: aCollection

| avg sample sum |
avg := aCollection average.
sample := aCollection anyOne.
sum := aCollection inject: sample into: [ :accum :each | accum + (each - avg) squared ].
sum := sum - sample.
^ sum = 0
ifTrue: [0]
ifFalse: [((sum / (aCollection size - 1)) sqrt) asScaledDecimal roundTo: 0.01]
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
"class" : {
},
"instance" : {
"addValues" : "joabe 7/1/2023 16:21" } }
"addValues" : "pre 7/22/2024 14:01",
"standardDeviation:" : "pre 7/22/2024 14:02" } }

0 comments on commit fb5973d

Please sign in to comment.