This commit is contained in:
Miloslav Ciz 2024-11-17 15:37:32 +01:00
parent 5f2a713689
commit 8dc4c812eb
11 changed files with 1838 additions and 1834 deletions

View file

@ -1,6 +1,6 @@
# Markov Chain
Markov chain is a relatively simple [stochastic](stochastic.md) (working with probability) mathematical model for predicting or generating sequences of symbols. It can be used to describe some processes happening in the [real world](real_world.md) such as behavior of some animals, Brownian motion or structure of a language. In the world of programming Markov chains are pretty often used for generation of texts that look like some template text whose structure is learned by the Markov chain (Markov chains are one possible model used in [machine learning](machine_learning.md)). Chatbots are just one example.
Markov chain is a relatively simple [stochastic](stochastic.md) (working with [probability](probability.md)) [mathematical](math.md) [model](model.md) for predicting or generating sequences of symbols. It can be used to describe some processes happening in the [real world](irl.md) such as behavior of some animals, Brownian motion or structure of a [language](human_language.md). In the world of [programming](programming.md) Markov chains are pretty often used for generation of texts that look like some template text whose structure is learned by the Markov chain (Markov chains are one possible model used in [machine learning](machine_learning.md)). Chatbots are just one example.
There are different types of Markov chains. Here we will be focusing on discrete time Markov chains with finite state space as these are the ones practically always used in programming. They are also the simplest ones.
@ -38,7 +38,7 @@ Now it's pretty clear this description gets a bit tedious, it's better, especial
| C | 0.1 | 0.1 | 0.7 | 0.1 |
| D |0.25 |0.25 | 0.5 | 0 |
We can see a few things: the NPC can't immediately attack from cover, it has to search for a target first. It also can't throw two grenades in succession etc. Let's note that this model will now be yielding random sequences of actions such as [*cover*, *search*, *shoot*, *shoot*, *cover*] or [*cover*, *search*, *search*, *grenade*, *shoot*] but some of them may be less likely (for example shooting 3 bullets in a row has a probability of 0.1%) and some downright impossible (e.g. two grenades in a row). Notice a similarity to for example natural language: some words are more likely to be followed by some words than others (e.g. the word "number" is more likely to be followed by "one" than for example "cat").
We can see a few things: the NPC can't immediately attack from cover, it has to search for a target first. It also can't throw two grenades in succession etc. Let's note that this model will now be yielding random sequences of actions such as [*cover*, *search*, *shoot*, *shoot*, *cover*] or [*cover*, *search*, *search*, *grenade*, *shoot*] but some of them may be less likely and some downright impossible (e.g. two grenades in a row). Notice a similarity to for example natural language: some words are more likely to be followed by some words than others (e.g. the word "number" is more likely to be followed by "one" than for example "cat").
## Code Example