-
Notifications
You must be signed in to change notification settings - Fork 0
Basic usages
medasmarathon edited this page May 29, 2022
·
4 revisions
from probnode import Outcome, Event, P__, ProbabilityDistribution, SampleSpace, RandomVariable, BaseEvent, GenericSureEvent
from probnode.computation import eval_p
outcome_head = Outcome("Head")
outcome_tail = Outcome("Tail")
sample_space = SampleSpace([outcome_head, outcome_tail])
@ProbabilityDistribution
def coin_tossing_probability_distribution(event: BaseEvent) -> float:
if event == Event(outcome_head):
return 0.3
if event == Event(outcome_tail):
return 0.7
random_var = RandomVariable(coin_tossing_probability_distribution, sample_space)
p_X = P__(random_var)
print(repr(p_X))
print(eval_p(p_X(Event(outcome_head))) # 0.3
print(eval_p(p_X(Event(outcome_tail))) # 0.7