Skip to content

Commit

Permalink
add standard deviation
Browse files Browse the repository at this point in the history
  • Loading branch information
oganm committed Aug 31, 2022
1 parent f0d295a commit 9391b2f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions addons/dice_syntax/dice_syntax.gd
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ static func expected_value(probs:Dictionary)->float:
out += probs[k]*float(k)
return(out)

static func standard_deviation(probs:Dictionary)->float:
var out = 0
var mean = expected_value(probs)
for k in probs.keys():
out += pow(float(k)-mean,2)*probs[k]
return pow(out,0.5)

static func roll_from_probs(probs:Dictionary,rng:RandomNumberGenerator,n=1)->Array:
var al = preload('array_logic.gd')
Expand Down
2 changes: 1 addition & 1 deletion addons/dice_syntax/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="dice_syntax"
description="Dice rolling syntax"
author="Ogan Mancarci"
version="2.1.3"
version="2.2.0"
script="plugin.gd"

0 comments on commit 9391b2f

Please sign in to comment.