Skip to content

Commit

Permalink
Merge pull request #4 from tomaskourim/presentation
Browse files Browse the repository at this point in the history
Presentation
  • Loading branch information
tomaskourim authored Jun 5, 2020
2 parents 2569b33 + 6338c65 commit 64f642e
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 60 deletions.
4 changes: 4 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@
BASE_GUESSES = [0.5, 0.8, 0.9, 0.7, 0.6, 0.2, 0.1, 0.4, 0.3]

DECIMAL_PRECISION = 40

TICKS_SIZE = 14
LABEL_SIZE = 25
TITLE_SIZE = 30
33 changes: 17 additions & 16 deletions graphs_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from common import exp_p_t_array, var_p_t_array, log_time, create_logger, exp_s_t_array, exp_p_s_t_array, var_s_t_array, \
exp_x_t_array, var_x_t_array
from config import MODEL_TYPES, REPETITIONS_OF_WALK_S, \
C_LAMBDAS_TESTING, START_PROBABILITIES_TESTING, STEP_COUNTS_TESTING, C_LAMBDA_PAIRS_TESTING
C_LAMBDAS_TESTING, START_PROBABILITIES_TESTING, STEP_COUNTS_TESTING, C_LAMBDA_PAIRS_TESTING, TICKS_SIZE, LABEL_SIZE, \
TITLE_SIZE
from data_generation import generate_random_walks, list_walks2list_lists, generate_random_walk_from_rand_array


Expand All @@ -32,11 +33,11 @@ def main(simulated_property="probability"):
model_max_y[model_index]
for p_index, starting_probability in enumerate(START_PROBABILITIES_TESTING):
plt.subplot(plt_rows, plt_columns, p_index + 1)
plt.title(r'$p_{0}=%.2f$' % starting_probability, fontsize=20)
plt.title(r'$p_{0}=%.2f$' % starting_probability, fontsize=TITLE_SIZE)
plt.axis([1, step_count, min_y, max_y])
plt.xlabel('steps', fontsize=18)
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
plt.xlabel('steps', fontsize=LABEL_SIZE)
plt.xticks(fontsize=TICKS_SIZE)
plt.yticks(fontsize=TICKS_SIZE)
for index, c_lambda in enumerate(C_LAMBDAS_TESTING):
if two_lambda:
c_lambdas = C_LAMBDA_PAIRS_TESTING[index]
Expand Down Expand Up @@ -113,27 +114,27 @@ def single_walk_simulation(model_type):
else:
two_lambda = False
# TODO handle with dignity
max_y = 80
min_y = -20
max_y = 1
min_y = 0

for p_index, starting_probability in enumerate(START_PROBABILITIES_TESTING):
rand_numbers = np.random.uniform(size=step_count)
plt.subplot(plt_rows, plt_columns, p_index + 1)
plt.title(r'$p_{0}=%.2f$' % starting_probability, fontsize=20)
plt.axis([1, step_count, min_y, max_y])
plt.xlabel('steps', fontsize=18)
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
plt.title(r'$p_{0}=%.2f$' % starting_probability, fontsize=TITLE_SIZE)
plt.axis([0, step_count, min_y, max_y])
plt.xlabel('steps', fontsize=LABEL_SIZE)
plt.xticks(fontsize=TICKS_SIZE)
plt.yticks(fontsize=TICKS_SIZE)
for index, c_lambda in enumerate(C_LAMBDAS_TESTING):
if two_lambda:
c_lambdas = C_LAMBDA_PAIRS_TESTING[index]
label = r'$\bar{\lambda}=[%.2f,%.2f]$' % (c_lambdas[0], c_lambdas[1])
else:
c_lambdas = [c_lambda]
label = r'$\lambda=%.2f$' % c_lambda
development = generate_random_walk_from_rand_array(rand_numbers, model_type, starting_probability,
c_lambdas, step_count).development
plt.plot(development, styles[index], label=label)
data_to_plot = generate_random_walk_from_rand_array(rand_numbers, model_type, starting_probability,
c_lambdas, step_count).probabilities
plt.plot(data_to_plot, styles[index], label=label)
plt.legend(loc='best', fontsize='xx-large', markerscale=3)
fig = plt.gcf()
fig.set_size_inches(18.5, 10.5)
Expand All @@ -147,5 +148,5 @@ def single_walk_simulation(model_type):
# main(simulated_property="probability")
# main(simulated_property="step")
# main(simulated_property="p_s")
single_walk_simulation("success_punished")
single_walk_simulation("success_punished_two_lambdas")
log_time(start_time, logger)
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
\usecolortheme{beaver}


\title{A model of random walk with varying transition probabilities}
\institute[FNSPE CTU]{\inst{1} Faculty of Nuclear Sciences and Physical Engineering, CTU Prague \and
\title{A Model of a Random Walk with Varying Transition Probabilities}
\institute[Tomáš Kouřim ([email protected])]{\inst{1} Faculty of Nuclear Sciences and Physical Engineering, CTU Prague \and
\inst{2} Institute of Information Theory and Automation, CAS CR Prague}
%\date{16.9.2019}
\date{SMTDA 2020}
\author[Tomáš~Kouřim]{Tomáš~Kouřim \inst{1} \and Petr Volf \inst{2}}
\newcommand{\nologo}{\setbeamertemplate{logo}{}} % command to set the logo to nothing
\setbeamertemplate{itemize item}[circle]
Expand All @@ -26,13 +26,7 @@
\begin{document}
\maketitle

\begin{frame}{Outline}
\begin{enumerate}
\item<1-> {\Large{}Motivation}\bigskip{}
\item<2-> {\Large{}Model description}\bigskip{}
\item<3-> {\Large{}Model application}
\end{enumerate}
\end{frame}
\section{Motivation}\label{sec:motivation}

\begin{frame}{Random walk}
\begin{definition}
Expand All @@ -52,6 +46,10 @@
\end{definition}
\end{frame}

\begin{frame}{Motivation - Random process with varying probability}
\includegraphics[width=1\textwidth]{../../simulations/probability_25_steps_type_success_punished_two_lambdas}
\end{frame}

\begin{frame}{Motivation}
\begin{itemize}
\item Failure of a machine
Expand All @@ -72,27 +70,32 @@
\end{itemize}
\end{frame}

\begin{frame}{Motivation - Random process with varying probability}
\includegraphics[width=1\textwidth]{../../simulations/probability_dots_25_steps_type_success_punished_two_lambdas}
\end{frame}

\section{Model description}\label{sec:model-description}
\begin{frame}{Random walk with varying probabilities}
\begin{itemize}
\item Random walk with memory
\item Memory coefficient $\lambda\in(0,\,1)$ affecting the transition probabilities
\item First step of the walk $X_{1}$ depends on an initial transition probability $p_{0}$
\item Further steps depend on a transition probability $p_{t}$ evolving as
\onslide<2->\begin{flalign*}
X_{t-1} & =1\rightarrow p_{t}=\lambda p_{t-1} &
X_{t-1} & =-1\rightarrow p_{t}=1-\lambda(1-p_{t-1}) &
\item<1-> Random walk with memory based the on standard Bernoulli random walk
\item<2-> Given starting probability $p_0$
\item<3-> $X_t\in\{-1,1\}$ with $X_t \sim {\textrm{Bernoulli} }(p_{t-1})$
\item<4-> Memory coefficient $\lambda\in(0,\,1)$ affecting the development of probabilities $p_{t}$ as
\onslide<4->\begin{flalign*}
X_{t} & =1\rightarrow p_{t}=\lambda p_{t-1} &
X_{t} & =-1\rightarrow p_{t}=1-\lambda(1-p_{t-1}) &
\end{flalign*}
\vspace{-5mm}
\begin{itemize}
\item[-->]<3-> ``Success punished''
\item[-->]<5-> ``Success punishing''
\end{itemize}
\onslide<4->\begin{flalign*}
X_{t-1}&=1\rightarrow p_{t}=1-\lambda(1-p_{t-1})&
X_{t-1}&=-1\rightarrow p_{t}=\lambda p_{t-1}&
\onslide<6->\begin{flalign*}
X_{t}&=1\rightarrow p_{t}=1-\lambda(1-p_{t-1})&
X_{t}&=-1\rightarrow p_{t}=\lambda p_{t-1}&
\end{flalign*}
\vspace{-5mm}
\begin{itemize}
\item[-->]<5-> ``Success rewarded''
\item[-->]<6-> ``Success rewarding''
\end{itemize}
\end{itemize}
\end{frame}
Expand Down Expand Up @@ -174,17 +177,20 @@
\end{frame}

\begin{frame}{Success rewarding model}
\onslide<2->
\begin{flalign*}
EX_{t} & =2p_{0}-1 &
\end{flalign*}
\vspace{-8mm}
\begin{flalign*}
Var\,X_{t} & =4p_{0}(1-p_{0}) &
\end{flalign*}
\onslide<1->
\begin{flalign*}
EP_{t} & =p_{0} &
\end{flalign*}
\vspace{-8mm}
\onslide<2->
\begin{flalign*}
Var\,P_{t} & =(2\lambda-\lambda^{2})^{t}p_{0}^{2}+p_{0}(1-\lambda)^{2}\sum_{i=0}^{t-1}(2\lambda-\lambda^{2})^{i}-p_{0}^{2} &
\end{flalign*}
Expand All @@ -197,9 +203,9 @@
\end{flalign*}
\end{frame}

\begin{frame}{Two-parameter model}
\begin{frame}{More complex models}
\begin{itemize}
\item Two $\lambda$ parameters each affecting one direction of the walk
\item Two memory coefficients $\lambda$ each affecting one direction of the walk
\item Again two variants -- success punishing and success rewarding
\onslide<2->\begin{flalign*}
X_{t-1} & =1\rightarrow p_{t}=\lambda_{0} p_{t-1} &
Expand All @@ -217,45 +223,47 @@
\begin{itemize}
\item[-->]<3-> ``Two-parameter success rewarding model''
\end{itemize}
\item<4-> $M$ steps, $\lambda(t)$, $n$-dimensional walk
\end{itemize}
\end{frame}

\begin{frame}{Example - two-parameter success punishing model}
\includegraphics[width=1\textwidth]{../../simulations/single_walk_1000_steps_type_success_punished_two_lambdas}
\end{frame}

\section{Model application}\label{sec:model-application}
\begin{frame}{Model fitting}
\begin{enumerate}
\item Find $\overrightarrow{\lambda}$ with known $p_{0}$, model type
\item Find $p_{0}$ with known $\overrightarrow{\lambda}$, model type
\item Find $p_{0},\,\overrightarrow{\lambda}$ with known model type
\item Find model type without any prior knowledge
\item Find $\lambda$ with known $p_{0}$, model type
\item Find $p_{0}$ with known $\lambda$, model type
\item Find $p_{0},\,\lambda$ with known model type
\item Find model type and all parameters without any prior knowledge
\end{enumerate}
\end{frame}

\begin{frame}{Model fitting}
\begin{enumerate}
\item Find $\overrightarrow{\lambda}$ with known $p_{0}$, model type
\item Find $p_{0}$ with known $\overrightarrow{\lambda}$, model type
\item Find $p_{0},\,\overrightarrow{\lambda}$ with known model type
\item Find $\lambda$ with known $p_{0}$, model type
\item Find $p_{0}$ with known $\lambda$, model type
\item Find $p_{0},\,\lambda$ with known model type
\begin{itemize}
\item Using maximal likelihood estimate \& numerical optimization
\item (1-3) maximal likelihood estimate \& numerical optimization
\end{itemize}
\item Find model type without any prior knowledge
\item Find model type and all parameters without any prior knowledge
\end{enumerate}
\end{frame}

\begin{frame}{Model fitting}
\begin{enumerate}
\item Find $\overrightarrow{\lambda}$ with known $p_{0}$, model type
\item Find $p_{0}$ with known $\overrightarrow{\lambda}$, model type
\item Find $p_{0},\,\overrightarrow{\lambda}$ with known model type
\item Find $\lambda$ with known $p_{0}$, model type
\item Find $p_{0}$ with known $\lambda$, model type
\item Find $p_{0},\,\lambda$ with known model type
\begin{itemize}
\item Using maximal likelihood estimate \& numerical optimization
\item (1-3) maximal likelihood estimate \& numerical optimization
\end{itemize}
\item Find model type without any prior knowledge
\item Find model type and all parameters without any prior knowledge
\begin{itemize}
\item Using Akaike information criterion \& numerical optimization
\item (4) Akaike information criterion \& numerical optimization
\end{itemize}
\end{enumerate}
\end{frame}
Expand All @@ -266,10 +274,10 @@
\item Model trained on 2009--2018 men Grand Slam tournaments
\item<2-> Model applied on 2019 US Open
\begin{itemize}
\item<2-> Live betting against bookmaker
\item<2-> $0.52$ units total necessary bankroll
\item<2-> $2.24$ units total profit $\rightarrow$ $430\%$ ROI
\item<3-> Only 128 bets placed
\item<3-> Live betting against bookmaker
\item<4-> Bankroll: $52$ units
\item<5-> Profit: $224$ units $\rightarrow$ $430\%$ ROI
\item<6-> Only 128 bets placed
\end{itemize}
\end{itemize}
\end{frame}
Expand All @@ -278,8 +286,8 @@
\begin{itemize}
\item A specific model of a random walk with memory
\item Model properties derived
\item Application shows big future potential of the model
\item Possible applications in a set of real life scenarios
\item Initial results show big potential of the model
\end{itemize}
\end{frame}

Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 64f642e

Please sign in to comment.