Priors
normalized_dict(d)
Examples:
>>> t_d = {'a': 1, 'b': 3}
>>> t_d = normalized_dict(t_d)
>>> t_d
{'a': 0.25, 'b': 0.75}
>>> t_d = {'c': 0, 'd': 0}
>>> t_d = normalized_dict(t_d)
>>> t_d
{'c': 0, 'd': 0}
Source code in src/equation_tree/util/priors.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
set_priors(priors=None, space=None)
Utility function to set priors without setting all probabilities of the space
Examples:
>>> default_priors = set_priors(space=['a', 'b', 'c', 'd'])
>>> default_priors
{'a': 0.25, 'b': 0.25, 'c': 0.25, 'd': 0.25}
>>> custom_priors_full = set_priors({'a' : .3, 'b': .7}, ['a', 'b'])
>>> custom_priors_full
{'a': 0.3, 'b': 0.7}
>>> custom_priors_partial = set_priors({'a' : .5}, ['a', 'b', 'c'])
>>> custom_priors_partial
{'a': 0.5, 'b': 0.25, 'c': 0.25}
Source code in src/equation_tree/util/priors.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|