27
Probability Adjustment Method Yonsei University Jamie J Seol

Probability Adjust Method

Embed Size (px)

Citation preview

Page 1: Probability Adjust Method

Probability Adjustment Method

Yonsei University

Jamie J Seol

Page 2: Probability Adjust Method

Motivation

Throw coin 10 times. You’ll expect 5 heads.

Page 3: Probability Adjust Method

Let’s try it with computer

1,000,000 tosses with no adjustment

-1000

-500

0

500

1000

1500

y-value = heads - tails

Page 4: Probability Adjust Method

Why not Horizon?

By Chevyshev inequality, the result should be horizon-like as n becomes bigger.

But it showed not, because of computer’s pseudo random generator.

Maximum difference of head-tail was 1554, which is 0.15% error and it’s not that critical.

Although, we want to adjust this error when using pseudo random.

Page 5: Probability Adjust Method

Object

We want n/2 heads out of n tosses.

Assume we can change probability of toss result.

If we got d tails in a row, then probability of head-up should be increased, responsible to d.

Using adjustment method, we can control how fast actual outcome converges into given probability.

Page 6: Probability Adjust Method

Example

Let h be number of heads-up, and t be number of tails-up in n tosses.

Let d = t – h.

For d > 0, changing probability of tails-up into (1/2)^d will produce stable result.

Page 7: Probability Adjust Method

Simulation of Previous Example

-20

-15

-10

-5

0

5

10

15

20

1,000,000 tosses with (1/2)^d

y-value = heads - tails

Page 8: Probability Adjust Method

Result of (1/2)^d

Maximum difference was 5, which gives 0.0005% error!

But this method converges into horizon too fast.

Page 9: Probability Adjust Method

Weighted Random

Changing probability directly into exponential value is too fragile.

How about giving weight into probability?

Page 10: Probability Adjust Method

Weighting Function

Using weighting function as exponent won’t be big problem.

We’ll use simple growth function from general MMORPG’s experience-level system.

Page 11: Probability Adjust Method

Weighted Random Function

If weighting function f is distributive, i.e.

then for , and random number

by defining ,

w(r) gives weighted random value.

Page 12: Probability Adjust Method

Choosing Weighting Function

For easy calculation, we’ll use simple exponential function that can consider d.

By letting weighting function like above, we can see that probability of higher values get more weight as n becomes higher, and of course, it’s distributive.

Page 13: Probability Adjust Method

Calculation of Weighted Random

With ,

weighting function w(x, n) will be

Therefore w(r, n) will likely to give higher value as n goes bigger.

Page 14: Probability Adjust Method

Graph of Weighting Function

k = 1, n = 2 k = 1, n = 4

Page 15: Probability Adjust Method

Adjustment #1

With former functions, we can adjust probability in accurate way. For example, if d = 5 which means total number of tails-up is ahead by 5 compared to total number of heads-up, then we might want next toss result to be head by 95%.

Page 16: Probability Adjust Method

Calculation

Page 17: Probability Adjust Method

Simulation with Adjustment #1

1,000,000 tosses with k = 3.5997

y-value = heads - tails

-20

-15

-10

-5

0

5

10

15

20

Page 18: Probability Adjust Method

Result of Adjustment #1

Although it’s calculation was perfect, which means that d = 5 will produce heads-up by 95%, it still converges too fast, even faster than directly changing probability into exponential!

Page 19: Probability Adjust Method

Adjustment #2

We’ll repeat similar adjustment method, but with more reasoning.

Let’s set situation as d = 100 producing tails in 95%.

In this case, k will be 0.180004

Page 20: Probability Adjust Method

Simulation with Adjustment #2

100,000 tosses with k = 0.180004

y-value = heads - tails

-20

-15

-10

-5

0

5

10

15

20

Page 21: Probability Adjust Method

Not Bad!

In this method, what we were actually doing was bounding maximum difference. But the result gave too rigid bound.

Why did this happen? Proportion of weighted random value giving bigger than 0.5 with n = 10, k = 0.180004 is about 68%.

Since weighing function gives exponential weight, we need more gradual one.

Page 22: Probability Adjust Method

Adjustment #3

Actually maximum difference from adjustment #2 gave 8, which is quite reasonable for 100,000 tosses. We’ll just make another case with more gradual version.

New situation is d = 1000 producing tails in 95%.

In this case, k will be 0.0180004

Page 23: Probability Adjust Method

Simulation with Adjustment #3

100,000 tosses with k = 0.0180004

y-value = heads - tails

-25

-20

-15

-10

-5

0

5

10

15

20

25

Page 24: Probability Adjust Method

Any idea?

Maybe we can use weighting function like

which gives 0.5 minimum weight to all productions, but calculating weighted random with this function is impossible for general case.

Page 25: Probability Adjust Method

Result

• This new method won’t directly touch probability directly.

• Although restriction power is stronger than it’s set-up, but we can control boundaries without strictly-rigid way, with exact calculation.

• Now coin will show 4~6 heads out of 10 tosses, if we desire.

Page 26: Probability Adjust Method

Thank You!

Jamie J Seol

Yonsei University, Joyfl CSO

[email protected]

fb.me/theeluwin, @theeluwin

Page 27: Probability Adjust Method

Appendix: Python Simulator Code

from random import randomt = 100000d = 0k = 0.0180004for i in range(t):

r = random() ** (1.0/(k * abs(d) + 1))if d == 0: d += -1 + 2 * round(r)elif r > 0.5: d += -1 * d / abs(d)else: d += d / abs(d)