```python
from sympy import symbols, exp, ln
```


```python
s1, s2, y = symbols('s1 s2 y')
v1, v2 = symbols('v1, v2')

n1 = (s1 - 1500) / v1
n2 = (s2 - 1500) / v2

f = 1 / (1 + exp(- (n1 - n2)))
```


```python

```


```python
f
```




$\displaystyle \frac{1}{e^{\frac{s_{2} - 1500}{v_{2}} - \frac{s_{1} - 1500}{v_{1}}} + 1}$




```python
l = y * ln(f) + (1 - y) * ln(1 - f)
```


```python
l
```




$\displaystyle y \log{\left(\frac{1}{e^{\frac{s_{2} - 1500}{v_{2}} - \frac{s_{1} - 1500}{v_{1}}} + 1} \right)} + \left(1 - y\right) \log{\left(1 - \frac{1}{e^{\frac{s_{2} - 1500}{v_{2}} - \frac{s_{1} - 1500}{v_{1}}} + 1} \right)}$




```python
from sympy import diff

s1_update = diff(l, s1)
v1_update = diff(l, v1)

s2_update = diff(l, s2)
s1_update
```




$\displaystyle \frac{y e^{\frac{s_{2} - 1500}{v_{2}} - \frac{s_{1} - 1500}{v_{1}}}}{v_{1} \left(e^{\frac{s_{2} - 1500}{v_{2}} - \frac{s_{1} - 1500}{v_{1}}} + 1\right)} - \frac{\left(1 - y\right) e^{\frac{s_{2} - 1500}{v_{2}} - \frac{s_{1} - 1500}{v_{1}}}}{v_{1} \left(1 - \frac{1}{e^{\frac{s_{2} - 1500}{v_{2}} - \frac{s_{1} - 1500}{v_{1}}} + 1}\right) \left(e^{\frac{s_{2} - 1500}{v_{2}} - \frac{s_{1} - 1500}{v_{1}}} + 1\right)^{2}}$




```python
update
```




$\displaystyle \frac{y e^{- s_{1} + s_{2}}}{e^{- s_{1} + s_{2}} + 1} - \frac{\left(1 - y\right) e^{- s_{1} + s_{2}}}{\left(1 - \frac{1}{e^{- s_{1} + s_{2}} + 1}\right) \left(e^{- s_{1} + s_{2}} + 1\right)^{2}}$




```python
# S1 is higher than s2 so it is expected to win and he does
# S1
conf = dict(s1=1500, s2=1400, y=1, v1=300, v2=35)
print(conf)
print('Probability of Winning:', f.evalf(subs=conf))
print('S1 Update: ', s1_update.evalf(subs=conf))
print('V1 Update: ', v1_update.evalf(subs=conf))
```

    {'s1': 1500, 's2': 1400, 'y': 1, 'v1': 300, 'v2': 35}
    Probability of Winning: 0.945686733867359
    S1 Update:  0.000181044220442135
    V1 Update:  -0.e-263



```python
# S1 is higher than s2 so it is expected to win but losses
# S1 is less consistent
conf = dict(s1=1500, s2=1400, y=0, v1=200, v2=400)
print(conf)
print('Probability of Winning:', f.evalf(subs=conf))
print('S1 Update: ', s1_update.evalf(subs=conf))
print('V1 Update: ', v1_update.evalf(subs=conf))
```

    {'s1': 1500, 's2': 1400, 'y': 0, 'v1': 200, 'v2': 400}
    Probability of Winning: 0.562176500885798
    S1 Update:  -0.00281088250442899
    V1 Update:  0



```python
# S1 is lower than s2 so it is expected to lose but win
conf = dict(s1=1400 / 1500, s2=1500 /1500, y=1)
print(conf)
print('Probability of Winning:', f.evalf(subs=conf))
print('Update: ', s1_update.evalf(subs=conf))
```

    {'s1': 0.9333333333333333, 's2': 1.0, 'y': 1}
    Probability of Winning: 0.483339503430589
    Update:  0.516660496569411



```python
# S1 is lower than s2 so it is expected to lose and he does
conf = dict(s1=1400 / 1500, s2=1500 /1500, y=0)
print(conf)
print('Probability of Winning:', f.evalf(subs=conf))
print('Update: ', s1_update.evalf(subs=conf))
```

    {'s1': 0.9333333333333333, 's2': 1.0, 'y': 0}
    Probability of Winning: 0.483339503430589
    Update:  -0.483339503430589



```python


```


```python

```


```python

```


```python

```


```python

```


```python

```


```python

```

389d02447074b381df420009c729ee1a75002996
ipynb
Jupyter Notebook
examples/scratch.ipynb
Delaunay/Ranked
287940019c3baf233fcc7b5d341f4ed8a0fdac6d
BSD-3-Clause
examples/scratch.ipynb
Delaunay/Ranked
287940019c3baf233fcc7b5d341f4ed8a0fdac6d
BSD-3-Clause
2022-03-13T02:53:06.000Z
2022-03-19T19:15:16.000Z
examples/scratch.ipynb
Delaunay/Ranked
287940019c3baf233fcc7b5d341f4ed8a0fdac6d
BSD-3-Clause
Qwen/Qwen-72B
1. YES
2. YES