#1859 - Started giving the red agent some 'intelligence' and a sense of a state. Changed Application.run to .execute.

This commit is contained in:
Chris McCarthy
2023-11-13 15:55:14 +00:00
parent 815bdfe603
commit 23fd9c3839
10 changed files with 151 additions and 34 deletions

View File

@@ -0,0 +1,16 @@
from random import random
def simulate_trial(p_of_success: float):
"""
Simulates the outcome of a single trial in a Bernoulli process.
This function returns True with a probability 'p_of_success', simulating a success outcome in a single
trial of a Bernoulli process. When this function is executed multiple times, the set of outcomes follows
a binomial distribution. This is useful in scenarios where one needs to model or simulate events that
have two possible outcomes (success or failure) with a fixed probability of success.
:param p_of_success: The probability of success in a single trial, ranging from 0 to 1.
:returns: True if the trial is successful (with probability 'p_of_success'); otherwise, False.
"""
return random() < p_of_success