PyMCSL auxiliary classes
DiscreteRandomVariable class
- class pymcsl.DiscreteRandomVariable(alphabet_and_weights: Dict[Union[str, int, float], Union[int, float]])
Random Variables are variables that give unpredictable outcomes. Discrete random variables have an alphabet, which is a set of possible outcomes, and a outcoming probability associated with each value in the alphabet. The act of getting a outcome from a random variable is called ‘evaluation’.
- Parameters
alphabet_and_weights (Dict[Union[str, int, float], Union[int, float]]) – Dictionary whose set of keys is the alphabet and the items are the probabilities. Format {outcome, probability}.
- evaluate() Union[str, int, float]
Get an outcome.
- Returns
outcome.
- Return type
Union[str, int, float]
SimpleMarkovChain class
- class pymcsl.SimpleMarkovChain(states: Set[Union[int, float, str]], transitions: List[Tuple[Union[int, float, str], Union[int, float, str], Union[int, float]]], initial_state: Union[int, float, str])
Markov Chains are graphs that represent stochastic processes based on random state transitions. The SimpleMarkovChain class is a Markov Chain simulator with constant transition probabilities.
- Parameters
states (Set[StateType], where StateType=Union[str, int, float]) – Set of states.
transitions (List[Tuple[StateType, StateType, WeightType]]) – List of transitions. Each transition is a tuple in the format (state1, state2, weight), where state1 is the initial state, state2 is the final state and weight is a value proportional to the transition probability.
initial_state (StateType) – Initial state.
- foward() Union[int, float, str]
Do a random transition.
- Returns
State after transition.
- Return type
StateType
- property state: Union[int, float, str]
Returns the current state.
- Returns
Current state.
- Return type
StateType