In probability and one wants to ensure/increase the chance of winning by choosing the most appropriate sequence of events. For Example, for people having business and trade in stock marketing, the martingale algorithm is simple and brilliant with some drawbacks.

**Need and Working of the Algorithm:**

- It can’t ensure profit always, but it can lead you as much close to the goal state as it can, under certain conditions give a predictable outcome in terms of profits.
- It doesn’t rely on an ability to predict the absolute market direction. This is useful given the dynamic and volatile nature of foreign exchange.

**Advantage of the Algorithm:**

In probability, a martingale is a sequence of random variables for which, at a particular time, the conditional expectation of the coming value in the sequence, regardless of all prior values, is equal to the present value.

**Definition:**

The definition of a discrete-time martingale is a discrete-time stochastic process (i.e., a sequence of random variables) **X1, X2, X3, …** that satisfies for any time **N**.

**Formula:**

=> E (| X

_{N}|) < infinity

=> E (X_{(N + 1)}| X_{1}, X_{2}, X_{3}, …. X_{N}) = X_{N}

That is, the conditional expected value of the next observation, given all the past observations, is equal to the most recent observation. Suppose that it is required to make a profit of **X coins** then below is the general examples for the same:

Let X be an integer.

- Bet X coins on odd.
- Let the roulette spin.
- If the outcome is odd, then prin the result.
- X:= 2 * X and then repeat the above procedure from the first step.

**Drawback: **

- It doesn’t have an infinite amount of money/coins. For arguments, say even numbers show up on
**9 consecutive spins**. Now it required 2^10 * X coins = 1024x coins are now required. - Also, another drawback is usually casinos have an upper limit on the bet you can place. In the very unlikely event of lots of consecutive losses, there will be a disaster.
- “I have enough coins and the amount of profit I want to make is considerably smaller, nearly 1% of the coins I have. What is the chance I stand to win this profit using the martingale algorithm?”.

**Probability:**

It is necessary to note that the property of being a martingale involves both the filtration and the probability measure (with respect to which the expectations are taken). It is possible that **Y** could be a martingale with respect to one measure but not another one; the Girsanov theorem offers a way to find a measure with respect to which an Itō process is a martingale.

**General Overview:**

Let us say the coins you have and the profit you want to make allow you to lose **at-most N** times in a row. The probability of losing (N + 1) times in a row is 1/(2^{(N + 1)}). This probability keeps getting smaller as **N increases**. For Example, if one can afford to lose 9 times in a row then the chance of winning the coins you want is 99.9990234%. This is a real-life application-based algorithm.

**Specific Example:**

**Example 1:** An unbiased random walk in the open space of our coordinate system in real numbers is an example of a martingale.

**Example 2:** Let Y_{N} = X_{(N2 – N) }where X_{N} is the person’s luck of winning from the previous experience. Then the sequence {Y_{N}: N = 1, 2, 3, …} is a martingale. This sequence can be used to show that the person’s total gain or loss varies roughly between plus or minus the square root of the number of steps.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer **Complete Interview Preparation Course****.**

In case you wish to attend live classes with industry experts, please refer **Geeks Classes Live** and **Geeks Classes Live USA**