\documentclass[10pt]{article}
\usepackage{fullpage}
\usepackage{setspace}
\usepackage{parskip}
\usepackage{titlesec}
\usepackage[section]{placeins}
\usepackage{xcolor}
\usepackage{breakcites}
\usepackage{lineno}
\usepackage{hyphenat}
\PassOptionsToPackage{hyphens}{url}
\usepackage[colorlinks = true,
linkcolor = blue,
urlcolor = blue,
citecolor = blue,
anchorcolor = blue]{hyperref}
\usepackage{etoolbox}
\makeatletter
\patchcmd\@combinedblfloats{\box\@outputbox}{\unvbox\@outputbox}{}{%
\errmessage{\noexpand\@combinedblfloats could not be patched}%
}%
\makeatother
\usepackage[round]{natbib}
\let\cite\citep
\renewenvironment{abstract}
{{\bfseries\noindent{\abstractname}\par\nobreak}\footnotesize}
{\bigskip}
\titlespacing{\section}{0pt}{*3}{*1}
\titlespacing{\subsection}{0pt}{*2}{*0.5}
\titlespacing{\subsubsection}{0pt}{*1.5}{0pt}
\usepackage{authblk}
\usepackage{graphicx}
\usepackage[space]{grffile}
\usepackage{latexsym}
\usepackage{textcomp}
\usepackage{longtable}
\usepackage{tabulary}
\usepackage{booktabs,array,multirow}
\usepackage{amsfonts,amsmath,amssymb}
\providecommand\citet{\cite}
\providecommand\citep{\cite}
\providecommand\citealt{\cite}
% You can conditionalize code for latexml or normal latex using this.
\newif\iflatexml\latexmlfalse
\providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}%
\AtBeginDocument{\DeclareGraphicsExtensions{.pdf,.PDF,.eps,.EPS,.png,.PNG,.tif,.TIF,.jpg,.JPG,.jpeg,.JPEG}}
\usepackage[utf8]{inputenc}
\usepackage[greek,english]{babel}
\usepackage{float}
% Use this header.tex file for:
% 1. frontmatter/preamble LaTeX definitions
% - Example: \usepackage{xspace}
% 2. global macros available in all document blocks
% - Example: \def\example{This is an example macro.}
%
% You should ONLY add such definitions in this header.tex space,
% and treat the main article content as the body/mainmatter of your document
% Preamble-only macros such as \documentclass and \usepackage are
% NOT allowed in the main document, and definitions will be local to the current block.
\begin{document}
\title{Summary of individual fish stochastic swimming model, and fitting
results}
\author[1]{Jacob Davidson}%
\affil[1]{Affiliation not available}%
\vspace{-1em}
\date{\today}
\begingroup
\let\center\flushleft
\let\endcenter\endflushleft
\maketitle
\endgroup
\sloppy
\section*{}
{\label{297056}}
\section*{October 17, 2017}
{\label{297056}}
\section*{Model description and
definitions}
{\label{297056}}
The basic form of this model is from~\cite{zienkiewicz_data-driven_2015}, which modified
the persistent-turning-walker model of \cite{gautrais_analyzing_2009} to also
include changes in speed. Let~\emph{s} be speed and be angular velocity.
The equations of motion are
\begin{align}
ds &= \alpha(s-\bar{s}+h_w(\mathbf x)) dt + \sigma_s dW(t) \\
d \omega &= -\lambda_\omega \omega + c_w f_w(\mathbf x,\theta)dt + \sigma_\omega B^{-s/\bar{s}} dW(t)
\end{align}
where~\(s\) is speed,~\(\omega\) is angular
velocity,~\(\mathbf{x}\) is position,~\(\theta\) is
orientation,~\(h_w(\mathbf x)\) is a wall force from the wall that acts
on speed,~\(f_w(\mathbf x,\theta)\) is a wall force that acts on turning,
and~\(B^{-s/\bar{s}}\) is an empirical function,
following~\cite{zienkiewicz_data-driven_2015}, which reduces the amplitude of the turning
fluctuations when the fish is going faster.~ Noise is represented by a
separate Wiener process (\(dW(t)\)) for each.
The things that are different from Zienkiewicz are:
\begin{itemize}
\tightlist
\item
The drag parameters are in different places in each equation.~ I found
this better for fitting, because~\(\lambda_\omega\) was usually large
(i.e. a short time constant.
\item
The empirical function for representing noise amplitude is simplified,
with a single parameter~\(B\) to fit, representing how
fast the amplitude of turning decreases with speed.
\item
The wall force that I `fit',~\(f_w(\mathbf{x},\theta)\), is inspired
by~\cite{calovi_disentangling_2017}.~ I also added another wall force that acts on
speed:~ ~\(h_w(\mathbf x)\)
\item
The average angular velocity is assumed to be zero, instead of being
fit.
\end{itemize}
\section*{Data input}
{\label{873730}}
This is data from Jolle a while ago, it is individual fish swimming in a
rectangular area:
\par\null\selectlanguage{english}
\begin{figure}[H]
\begin{center}
\includegraphics[width=1.00\columnwidth]{figures/all-fish-traj/all-fish-traj}
\caption{{Tracks of the fish.~ They clearly follow the wall
{\label{337363}}%
}}
\end{center}
\end{figure}
The tracking yields (x,y) coordinates and the orientation of the fish.~
I defined `speed' as a scalar, but allowing it be negative, by taking
the sign of the velocity dotted with the orientation of the fish.~ This
means that pretty mu ch always the fish has positive speed (i.e. is
moving forward), but that moving backwards (which sticklebacks do via
side fins) is represented by a negative speed.
I used `orientation' to correspond to angular velocity.~ If instead
`heading' is used, which can compute from the changes in (x,y)
positions, the results differ, because the low speed headings are hard
to define (even when considering negative speed).~ Every way I did it,
there were very large fluctuations in the calculated heading at low
speeds, while the orientations changes were smooth and better
represented actual movement.~ So, I will use `orientation' in all parts
of the data analysis.
\par\null
\section*{Fitting procedure}
{\label{347841}}
Using the ref provided by~\cite{zienkiewicz_data-driven_2015}, I
followed~\cite{van_den_berg_calibrating_2011}, who posted some notes on how to use either
maximum likelihood or least-squares to fit the parameters.~ I'll briefly
describe this procedure, and then how I went forward with fitting other
parameters.
\subsection*{Speed equation}
{\label{493580}}
For the speed equation, the procedure is the same as \cite{van_den_berg_calibrating_2011}. Neglecting the wall force, the solution is
$$ s_{t+1} = s_{t}e^{-\alpha_s \Delta t} + \bar{s}\left(1-e^{-\alpha_s \Delta t} \right) + \sigma_s \sqrt{\frac{1-e^{-2\alpha_s \Delta t}}{2 \alpha_s}} N_{0,1},$$
where $s_{t+1}$ is the next time step, and $N_{0,1}$ is a standard normal distribution.
For the least-squares fit, define a linear regression
$$ s_{t+1} = m s_{t}+b, $$
use the fit parameters $m$ and $b$ to determine $\alpha_s$ and $\bar{s}$, and then get the 'error' to define the noise amplitude as
$$ \sigma_s^2 = \left< \left(s_{t+1} -m s_{t} - b \right)^2 \right> \frac{-2\ln{m}}{\Delta t(1-m^2)}. $$
A maximum likelihood fit can be used also. It is more complicated but conceptually similar, in that you look at how the speed at the next time step changes from the current step. Note that this neglects wall effects on speed - I think this is a reasonable approximation, because the wall affects turning more than speed. The maximum likelihood and least squares results are nearly identical, because the error seems indeed to be Gaussian. I will report the least squares fit results.
\subsection*{Turning equation}
{\label{570648}}
For the turning equation, its a bit more complicated, because the wall
force definitely affects it.~ The turning equation can be solved
analytically and expressed in integral form - I worked through this,
using~\cite{springer}.~ Using only the assumption that the wall force
and speed amplitude are approximately constant across a single time step
(which should be a fine approx), then the difference between successive
time steps can be written the same way as the speed equation.~ The
result is
\begin{equation}
\omega_{t+1} = \omega_t e^{-\lambda_\omega \Delta t} + \frac{c_w f_w(\mathbf{x}_t,\theta_t)}{\lambda_\omega}\left(1-e^{-\lambda_\omega \Delta t} \right) +
\sigma_\omega B^{-s_t/\bar{s}} \sqrt{\frac{1-e^{-2\lambda_\omega \Delta t}}{2 \lambda_\omega}} N_{0,1}
\label{eq:angvel}
\end{equation}
So now we need to determine the following fit parameters in this equation: $\lambda_\omega$ (represents autocorrelation), $c_w$ and $\sigma_\omega$ (amplitudes for wall and noise effects), and $B$ (change in turning noise amplitude with speed). But we also want to fit a form for the function $f_w(\mathbf x, \theta)$. To do the fitting, if the function $f_w(\mathbf x, \theta)$ and parameter $B$ are defined, then can use the same procedure as did with speed (either linear regression or maximum likelihood), to get the rest of the parameters. So I'll first get $B$, then determine wall force, then do a regression to get other parameters.
\subsection*{Amplitude of turning changes with
speed}
{\label{990613}}
To fit $B$, consider the variance of angular velocity as a function of speed in the form
\begin{align}
\omega(s)^2 &\sim B^{-2s/\bar{s}} \\
& = c B^{-2s/\bar{s}},
\end{align}
where $c$ is a constant. Averaging over all speeds greater than zero, can get the constant factor as
$$ c = \frac{\left< \omega(s)^2 \right>}{\left< B^{-2s/\bar{s}} \right>}, $$
leading to the self-consistent expression
$$ \omega(s)^2 = \frac{\left< \omega(s)^2 \right>}{\left< B^{-2s/\bar{s}} \right>} B^{-2s/\bar{s}}. $$
To determine $B$ in this relationship, now do the following:
\begin{enumerate}
\item Use the approximate average $\left< B^{-2s/\bar{s}} \right> \approx B^{-2}$, and fit $B$ to the equation
$\omega(s)^2 = \left< \omega(s)^2 \right> B^{2-2s/\bar{s}} $
\item Use the fit value of $B$ to calculate $Q=\left< B^{-2s/\bar{s}} \right>$.
\item Use this value of $Q$ to fit $B$ in the equation $ \omega(s)^2 = \frac{\left< \omega(s)^2 \right>}{Q} B^{-2s/\bar{s}} $ (this can be done via linear regression by taking the log).
\item Repeat steps 2-3 until $B$ converges.
\end{enumerate}
\subsection*{Fitting parameters for different
fish}
{\label{200879}}
The methods described above give well-defined fit values for the
parameters associated with speed, and for~\emph{B}.~ Here are results
for the 8 different fish:
$$
\begin{array}{l|cccccccc}
\text{Fish number} & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\
\alpha _s\text{: inverse decay time} & 2.80495 & 3.69522 & 3.08673 & 2.56408 & 2.30195 & 6.83838 & 8.21498 & 3.1078 \\
\bar{s}\text{: average speed} & 94.5968 & 115.346 & 132.167 & 122.003 & 92.7337 & 69.6428 & 76.9634 & 96.7991 \\
\sigma _s\text{: fluctuations in speed} & 184.386 & 221.358 & 197.615 & 207.162 & 142.613 & 253.79 & 274.618 & 228.369 \\
\text{B: decrease in turning amplitude} & 2.63459 & 4.07886 & 3.81639 & 3.13348 & 2.7072 & 2.36478 & 3.02518 & 2.09063 \\
\end{array}
$$
If lump all the data together, get B=2.70.
\section*{Wall force}
{\label{225886}}
To fit wall force, I tried a method following~\cite{calovi_disentangling_2017}.~ I
defined the~coordinate system in the same way as they did:
\par\null\selectlanguage{english}
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.70\columnwidth]{figures/wall-coordinate-system/wall-coordinate-system}
\caption{{This is a caption
{\label{710601}}%
}}
\end{center}
\end{figure}
Calovi et al. use the empirical function
$$ f_w(\mathbf x, \theta) = f(r_w)g(\theta_w),$$ with $f(r_w)=\exp(-r_w^2/l_w^2)$ and $g(\theta_w) = \sin(\theta_w)(1+0.7 \cos(2\theta_w)$. I tried this and also some other forms, as well as using gradient descent to fit coefficients without a closed form. The function $f(r_w)$ is reasonable, just representing a decay in magnitude away from the wall, so I kept it, and varied the angular dependence in the parametric fits.
In a square or rectangular tank, there are 4 walls. I numbered them as shown below (also showing lengths of the sides):\selectlanguage{english}
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.70\columnwidth]{figures/wall-numbers/wall-numbers}
\end{center}
\end{figure}
Then the total force from the walls is a sum over the closest two walls
(could do all, but expect it to decay with distance, so I think this is
fine):
\par\null
$$ f_w(\mathbf x, \theta) = \sum_{q=1}^{2\text{ walls}} f(r_{w,q})g(\theta_{w,q}), $$
where for example~\(\theta_{w,q}\) is the angle that the fish makes
with wall~\emph{q}.
\subsection*{Different fits, with data from all the fish grouped
together.~}
{\label{432903}}\par\null\selectlanguage{english}
\begin{figure}[H]
\begin{center}
\includegraphics[width=1.00\columnwidth]{figures/sin2/sin2}
\caption{{Sin Function fit.~ A-\textgreater{}1.81349,L-\textgreater{}24.5581~
{\label{248288}}%
}}
\end{center}
\end{figure}\selectlanguage{english}
\begin{figure}[H]
\begin{center}
\includegraphics[width=1.00\columnwidth]{figures/sincosshifted1/sincosshifted1}
\caption{{Shifted sin cos series.~~A -\textgreater{} 0.715373, L -\textgreater{}
23.8402, A1 -\textgreater{} -2.54454, A2 -\textgreater{} 1.00693, B1
-\textgreater{} 3.3657, B2 -\textgreater{} 1.45216
{\label{720357}}%
}}
\end{center}
\end{figure}\selectlanguage{english}
\begin{figure}[H]
\begin{center}
\includegraphics[width=1.00\columnwidth]{figures/sincosseries/sincosseries}
\caption{{Sin cos series.~~A -\textgreater{} 1.60237, L -\textgreater{} 52.1835,
A1 -\textgreater{} 1.66459, A2 -\textgreater{} -0.444674, B1
-\textgreater{} 0.482004, B2 -\textgreater{} 0.946792
{\label{269672}}%
}}
\end{center}
\end{figure}\selectlanguage{english}
\begin{figure}[H]
\begin{center}
\includegraphics[width=1.00\columnwidth]{figures/calovi/calovi}
\caption{{Function used by Calovi with extra fit parameter:~~A -\textgreater{}
2.45093, L -\textgreater{} 43.6965, a -\textgreater{} 0.899014
{\label{720539}}%
}}
\end{center}
\end{figure}
The sin and cos series, and the form from Calovi, seem to do well.~ The
main difference between the results in Figs
~{\ref{248288}} and~{\ref{720357}},
versus those in~{\ref{269672}}
and~{\ref{720539}}, is that the fits in
~{\ref{248288}} and~{\ref{720357}}
allow for two stable fixed points, while the fits in
{\ref{269672}} and~{\ref{720539}} only
have a single one.~ This also depends on the sign on the coefficient
c\_w, but I got positive values for all cases, so the above figures are
straightforward to interpret.
Figures~{\ref{248288}}
and~{\ref{720357}} have stable fixed points at~\selectlanguage{greek}π/\selectlanguage{english}2 and-
\selectlanguage{greek}π/\selectlanguage{english}2:~ this corresponds to swimming ``along the wall''.
Figures~{\ref{269672}}
and~{\ref{720539}} have a stable fixed point only at~\selectlanguage{greek}π
\selectlanguage{english}(or -\selectlanguage{greek}π\selectlanguage{english}).~ This corresponds to swimming ``away from the wall''.~
~However, the dynamics become slow near both~\selectlanguage{greek}π/\selectlanguage{english}2 and- \selectlanguage{greek}π/\selectlanguage{english}2, meaning that
turning will be slower when orientation is near these angles.~ These
functions can lead to either clockwise of counterclockwise swimming
around the arena, if the speed if set just right.~ However, with
stochastic changes in speed, the density of how the fish uses space in
the arena in a simulation doesn't really match the experimental data
(will put some comparisons and plots below).
To generalize, I did something similar to Calovi, and defined an error
function, and then fit coefficients via gradient descent
\par\null
$$ E = \sum_t \left( \omega(t+1) - f(r_{w,1}(t))g(\theta_{w,1}(t)) - f(r_{w,2}(t))g(\theta_{w,2}(t)) \right)^2, $$
where $f(r_w)$ represents a coefficient $f_i$, depending on the value of $r_w$, and similarly $g(\theta_w)$ represents a coefficient $g_k$, depends on the value of $\theta_w$. These discrete coefficients are then found by minimizing the error $E$, using a gradient descent algorithm.
The fit to this compared very well with the sin and cos series
representation, and also pretty good the form from Calovi:
\par\null\selectlanguage{english}
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.70\columnwidth]{figures/Calovi-comp/Calovi-comp}
\caption{{Normalized coefficients fit via gradient descent (gray, points),
compared to the parametric fit used by Calovi
(Fig~{\ref{720539}} fit).
{\label{205410}}%
}}
\end{center}
\end{figure}\selectlanguage{english}
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.70\columnwidth]{figures/Series-comp/Series-comp}
\caption{{Normalized coefficients fit via gradient descent (gray, points),
compared to the sin and cos series fit
(Fig~{\ref{269672}} fit).
{\label{416908}}%
}}
\end{center}
\end{figure}
I also tried using a 2D position function times an angular function,
which makes the fitting methods more similar to Calovi, but after
revisions this wasn't giving very good results.~
\section*{Angular velocity parameters}
{\label{617439}}
With defined forms for the wall force and the coefficient~\emph{B}, can
get the other parameters for angular velocity changes:~
~\(\lambda_\omega\),~\(c_w\) and~\(\sigma_\omega\).~ The
parameters~\(\lambda_\omega\) and~\(c_w\) are obtained by
doing a model fit to the equation
$$ \omega_{t+1} = \omega_t e^{-\lambda_\omega \Delta t} + \frac{c_w f_w(\mathbf{x}_t,\theta_t)}{\lambda_\omega}\left(1-e^{-\lambda_\omega \Delta t} \right) \equiv Q_t, $$
where $\omega_{t+1}$ is from the data, and $f_w(\mathbf{x}_t,\theta_t)$ is from the fit of the wall force. I am using $Q_t$ to represent the RHS of the equation. I used a normal fitting function in Mathematica to fit this (NonlinearModelFit). Then with these parameter values the noise amplitude parameter is calculated as
$$
\sigma_\omega^2 = \frac{\left< \left(\omega_{t+1}-Q_t \right)^2 \right>}{\left< B^{-2s/\bar{s}} \right>} \frac{2\lambda_\omega}{1-e^{-2\lambda_\omega \Delta t}}
$$
which is the same way as the speed noise amplitude parameter was
calculated, but just rewritten here a bit.
Here are the coefficients:\selectlanguage{english}
\begin{table*}[H]
\centering
\normalsize\begin{tabulary}{1.0\textwidth}{CCCC}
Model & \textbackslashlambda\_\textbackslashomega & c\_w & \textbackslashsigma\_\textbackslashomega \\
Sin & 34.35 & 36.5 & 57.87 \\
Sin Cos series -- shifted & 34.5 & 29.9 & 58.0 \\
Sin Cos series & 35.94 & 28.37 & 58.75 \\
Calovi & 35.79 & 25.43 & 58.74 \\
\end{tabulary}
\end{table*}This is consistent across different forms for f\_w used, which was
reassuring (once I got it to work!).~ The main interpretation of this is
that the autocorrelation time of changes in angular velocity is small.~
The effective time constant is~\(1/\lambda_\omega\), which is about 1/30
here, or one frame (frame rate in data was 30 fps).~ So, angular
velocity is very weakly correlated between timesteps in the data, and
does not persist for very long.
\par\null
\section*{Other rules/forces defined to do
simulation}
{\label{617439}}
With this, the main parts of the equations of motion are defined.~
Almost can simulate!~ But I added a few things and need to specify one
more function, in order to keep the fish inside the arena
\subsection*{Reduce speed near the wall, to prevent going through
it}
{\label{981598}}
I used the function $h_w(\mathbf x) = \bar{s} \exp[-d_w^2/\delta^2]$ to reduce the speed of the fish when it gets near the wall, where $d_w$ is the distance to the closest wall, and I used $\delta=1$, i.e. a very short range force.
\subsection*{Speed must be positive, unless near the
wall}
{\label{506811}}
When $d_w>\delta$, I say that speed must be greater than or equal to zero. I enforce this by simply thresholding speed during updates.
\subsection*{\texorpdfstring{If can't `turn away' from the wall, increase
amplitude of turning fluctuations until a choice of turn is made that
keeps the fish inside the
arena}{If can't turn away from the wall, increase amplitude of turning fluctuations until a choice of turn is made that keeps the fish inside the arena}}
{\label{871612}}
Along with the function~\(h_w\), I make an additional rule to
keep the fish inside the wall:~ if the next position would be outside
the wall, then regenerate the random numbers and keep re-drawing to set
speed and turning rate, until the next position will be inside the wall.
\section*{Individual fish fits for wall
force}
{\label{655994}}
Using the parametric forms, can fit the wall force from the individual
fish data, and get something reasonable!
$$
\begin{array}{c|ccc}
\text{fish num.}&\lambda _{\omega } & c_w & \sigma _{\omega } \\
1& 15.1388 & 5.88681 & 31.1838 \\
2& 46.2456 & 40.9988 & 101.537 \\
3& 23.9728 & 21.7041 & 46.4608 \\
4& 21.261 & 14.2057 & 42.522 \\
5& 20.8673 & 16.8016 & 30.1933 \\
6& 37.5522 & 27.4515 & 62.7624 \\
7& 69.0109 & 58.1066 & 108.821 \\
8& 44.564 & 41.7044 & 40.3748
\end{array}
$$
\section*{}
{\label{655994}}
The force functions are pretty similar for the different fits, here
showing when use the Sin and Cos series:\selectlanguage{english}
\begin{figure}[H]
\begin{center}
\includegraphics[width=1.00\columnwidth]{figures/allfitfw/allfitfw}
\caption{{All fit force functions.
{\label{288329}}%
}}
\end{center}
\end{figure}
\section*{Simulation results}
{\label{655994}}\par\null\selectlanguage{english}
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.70\columnwidth]{figures/compare---fit-fish-5/compare---fit-fish-5}
\caption{{Fit parameters for fish 5:~ Comparing simulation and data:~
distributions and density, space use in arena.
{\label{982144}}%
}}
\end{center}
\end{figure}\selectlanguage{english}
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.70\columnwidth]{figures/compare---fit-all/compare---fit-all}
\caption{{Simulation after fitting the wall force turning functions to all fish,
but keeping the speed-changing parameters from fish 5.
{\label{370636}}%
}}
\end{center}
\end{figure}
\subsection*{Simulation video}
{\label{484743}}
This corresponds to the simulation shown in Fig 11.
\href{https://www.dropbox.com/s/f5kh47gapie9fuy/PTWfitsims.mp4?dl=0}{Simulation
video - click to view or download from Dropbox}~
\par\null
\section*{Comments on model}
{\label{678781}}
\subsection*{Questions or possible changes to improve the form of this
model, to make it more
realistic:}
{\label{512539}}
\begin{enumerate}
\tightlist
\item
~ Fit the wall speed force, instead of assuming a form
for~\(h_w(\mathbf x)\)
\item
The amplitude of random changes in speed may depend on the wall
\item
The amplitude of random changes in angular velocity may depend on the
wall, such as modeled in~\cite{calovi_disentangling_2017}.
\item
The wall forces~\(h_w(\mathbf x)\) and~~\(f_w(\mathbf{x},\theta)\), or maybe
just~~\(f_w(\mathbf{x},\theta)\), could depend on speed.~ For example,
having~~\(f_w(\mathbf{x},\theta,s)\).~ A simple way to first do this would be do
use~\(B^{-s/\bar{s}}\) to represent a decrease in amplitude with
speed.
\item
``Negative speed'' could be treated more systematically than I
currently do, by fitting something, or defining rules from data
\end{enumerate}
\subsection*{What differs between this and Calovi
2017?}
{\label{287220}}
\begin{itemize}
\tightlist
\item
The speed dependence on angular turning noise amplitude was not
included in Calovi.~~
\item
However, Calovi included a term for angular turning noise amplitude to
decrease when closer to the wall
\end{itemize}
\section*{}
{\label{795058}}
\section*{Update: Nov 14, 2017}
{\label{795058}}
I modified the fit procedure in order to also fit speeding wall force,
in a similar way to the turning wall force.~ Changing slightly the
notation and parameter definitions, the equations of motions are now
\begin{align}
ds &= \lambda_s(\mu_s+h_w(\mathbf x,\theta)-s) dt + \sigma_s dW(t) \\
d \omega &= \lambda_\omega\left(f_w(\mathbf x,\theta)-\omega \right)dt + \sigma_\omega B_\omega^{-s/\mu_s dW(t)
\end{align}
For the wall speeding force, I used a similar form to the wall turning force:
\begin{equation}
h_w(\mathbf x,\theta)=\sum_{q=1}^{2\text{ walls}} f_s(r_{w,q}) g_s(\theta_{w,q}),
\end{equation}
where I used the same form for the distance dependence, $f_s(r_w)=A\exp(-r_w^2/l_w^2)$. For the angle dependence, I had good results with the cosine series expansion: function
$$g_s(\theta_w) = -\sum_{k=1}^4 B_k \cos k\theta + \sum_{k=1}^4 B_k (-1)^{k},
$$
where the second term enforces the reasonable condition that $g_s(-\pi)=g_s(\pi)=0$. Below I will compare with to the gradient descent solution.
Now, with these changes, the fit procedure is as follows:
\begin{enumerate}
\item Fit the speed parameters $\lambda_s$, $\mu_s$, and $\sigma_s$, using least-squares, first setting $h_w=0$
\item Fit the speed force $h_w(\mathbf x,\theta)$
\item Re-fit the speed parameters $\lambda_s$, $\mu_s$, and $\sigma_s$, using updated $h_w(\mathbf x,\theta)$
\item Repeat steps 2-3 until get convergence. Usually only $\mu_s$ changes significantly, other parameters and the force function don't change as much
\item Fit $B_\omega$, using the iterative procedure described above
\item Fit the wall turning forces $f_w(\mathbf x,\theta)$, using the procedure described above
\item Fit the other turning parameters: $\lambda_\omega$ and $\sigma_\omega$
\end{enumerate}
\subsection*{Example fit}
{\label{628925}}
Using data from~fish 4:
\par\null
\begin{figure}[H]
\begin{center}
\includegraphics[width=1.00\columnwidth]{figures/fish4-speedforce/fish4-speedforce}
\caption{Speeding force:~ f(r), g(theta), and correlation
{\label{293053}}%
}
\end{center}
\end{figure}
\begin{figure}[H]
\begin{center}
\includegraphics[width=1.00\columnwidth]{figures/fish4-turnforce/fish4-turnforce}
\caption{Turning force:~ f(r), g(theta), and correlation
{\label{184394}}%
}
\end{center}
\end{figure}
\par\null
\subsection*{Speeding wall force, fit by gradient descent, and by
parametric
form}
{\label{628925}}
To test whether the series expansion for the speeding wall force was
reasonable, I used gradient descent to fit parameters in discrete
intervals, and then compared the result to the parametric form with the
exp and cos functions.~ For this, I grouped all the data together.~
Grouping the data together does not give very good results for the
stochastic motion parameters, especially for~\(\lambda_s\)
and~~\(\sigma_s\), but it seemed to give the best representation
of the functional form that worked well.:
\par\null
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.70\columnwidth]{figures/gradientdescent-speedforce/gradientdescent-speedforce}
\caption{Parametric form (red lines) compared to gradient descent solution (grey
points)
{\label{771993}}%
}
\end{center}
\end{figure}
In this comparison, I normalized the exponential function
in~~\(f_s(r_w)\).~ I found that the magnitude from gradient
descent solution was much higher.~ I'm not sure why this is - it seems
like a bug in the code, but I couldn't find it.~ The angular dependence
converged very nicely, but the magnitude for the exponential function
kept increasing, and converges to a much higher value.~ This would need
to be addressed/figured out whats going on, to really make this
comparison, e.g. for paper/conference.
\par\null
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.28\columnwidth]{figures/gradientdescent-speedforce-exponential-magnitude/gradientdescent-speedforce-exponential-magnitude}
\caption{Magnitude of the fit from gradient descent is much larger than using the
parametric form - I'm not sure why~
{\label{440789}}%
}
\end{center}
\end{figure}
\subsection*{Comparison of simulation and data
distributions}
{\label{982837}}
For these simulations, I removed the rule that speed must be positive
unless near the wall.~ The most notable differences in these
distributions between the data and the simulation, are
\begin{enumerate}
\tightlist
\item
The angular velocities in the simulation seem to be higher than the
data.
\item
Although the simulated fish~ does spend a higher amount of time near
the walls, it uses the whole arena.~ Versus the data, where the fish
just follows the wall
\end{enumerate}
\par\null
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.70\columnwidth]{figures/compare-dists-with-speeding-force/compare-dists-with-speeding-force}
\caption{Simulation and data compared, for fish 4
{\label{538897}}%
}
\end{center}
\end{figure}
\href{https://www.dropbox.com/s/4a96uw950dpiz95/PTWfit-speedforce-sim.mp4?dl=0}{Short
video of this simulation (click link)}
\par\null
\section*{Update December 19, 2017}
{\label{819724}}\par\null
\selectlanguage{english}
\FloatBarrier
\bibliographystyle{plainnat}
\bibliography{bibliography/converted_to_latex.bib%
}
\end{document}