Last active
July 15, 2019 18:33
-
-
Save lavaboom/8a9dfd0fc2b51a0c6be86173feeb3317 to your computer and use it in GitHub Desktop.
Revisions
-
lavaboom revised this gist
Jul 15, 2019 . 1 changed file with 2 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,6 @@ def get_random_option_from_weight(options, weights): ''' python 3.6 and later ''' import random return random.choices(options, weights)[0] -
lavaboom revised this gist
Jul 15, 2019 . 1 changed file with 11 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,14 @@ def get_average_stat(times, func, params): tally = 0.0 for i in range(times): tally += func(params) print('Average stat: {}'.format(tally/times)) return tally/times def get_random_option_from_weight(options, weights): ''' python 3.6 and later ''' from random import choices options = [1, 2, 3, 4, 5, 6] weights = [0.1, 0.05, 0.05, 0.2, 0.4, 0.2] return choices(options, weights) -
lavaboom created this gist
Jul 15, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ def get_average_stat(times, func, params): ''' run <func> <times> with given <params> and return the average statistics ''' tally = 0.0 for i in range(times): tally += func(params) print('Average stat: {}'.format(tally/times)) return tally/times