Jekyll2021-11-29T03:50:55+00:00//benlansdell.github.io/feed.xmlBen LansdellApplied mathematics, deep learning, neuroscience, causalityBen Lansdellben dot lansdell at gmail dot comCausal inference algorithms for learning in neural networks2020-04-06T00:00:00+00:002020-04-06T00:00:00+00:00//benlansdell.github.io/neuroscience/causalneuro<p>A number of challenges in both machine learning (ML) and neuroscience are related to causation. In ML, causality relates to issues of transfer and generalization, fairness, and safety; and in neuroscience it relates to issues of interpretability and models of efficient learning. It can thus be beneficial to explicitly cast problems in both machine learning and neuroscience as causal inference problems.</p>
<p>Recently at Drexel, I gave <a href="https://benlansdell.github.io/facultytalk/#/">this</a> presentation, in which I explore this hypothesis in the context of learning in neural networks. I cover my research showing that framing the gradient estimation problem as one of causal inference can lead to new learning algorithms in spiking neural networks. These algorithms rely on, rather than smooth out, the spiking discontinuity. I then show how such causal effect estimators can be used to train weights of a feedback network to communicate gradient signals in a way that avoids the biologically implausible elements of the back-propagation algorithm. The result is learning algorithms with comparable performance to back-propagation, and better performance than other biologically plausible gradient-based learning rules, on simple benchmarks. These approaches thus yield efficient and plausible learning algorithms for the brain, which also have applications in neuromorphic hardware and specialized hardware optimized for implementing back-propagation.</p>
<p>Check out the slides here: <a href="https://benlansdell.github.io/facultytalk/#/">slides</a></p>Ben Lansdellben dot lansdell at gmail dot comA number of challenges in both machine learning (ML) and neuroscience are related to causation. In ML, causality relates to issues of transfer and generalization, fairness, and safety; and in neuroscience it relates to issues of interpretability and models of efficient learning. It can thus be beneficial to explicitly cast problems in both machine learning and neuroscience as causal inference problems.What is computational neuroscience?2020-04-05T00:00:00+00:002020-04-05T00:00:00+00:00//benlansdell.github.io/neuroscience/compneuro<p>Recently I had the opportunity to give a talk to the undergraduate student physics group at Western University. It was a fun exercise to reflect my area of research, computational neuroscience. I introduce the basic questions and framing of the field of computational neuroscience. In particular, focusing on the idea that what separates the field from other areas of mathematical and theoretical biology is its emphasis on <em>computations</em> of the brain. So computers and computation must be defined first, before going further. Check out the slides <a href="https://benlansdell.github.io/compneurointro">here</a>!</p>Ben Lansdellben dot lansdell at gmail dot comRecently I had the opportunity to give a talk to the undergraduate student physics group at Western University. It was a fun exercise to reflect my area of research, computational neuroscience. I introduce the basic questions and framing of the field of computational neuroscience. In particular, focusing on the idea that what separates the field from other areas of mathematical and theoretical biology is its emphasis on computations of the brain. So computers and computation must be defined first, before going further. Check out the slides here!The intertwined histories of computer science and the brain2019-09-18T00:00:00+00:002019-09-18T00:00:00+00:00//benlansdell.github.io/neuroscience/compneuro<p>Doing the rounds a while was an article posted on Aeon about how the brain is not a computer (<a href="https://aeon.co/essays/your-brain-does-not-process-information-and-it-is-not-a-computer">here</a>). How there is a fundamental difference between computers and brains in their structure, function and purpose. While it may be true that the brain does not function in the same way the laptop in front of me functions – processing bits of information in a predominantly serial fashion, with separated memory and processing components – this does not mean that the brain is not a computer in a more general sense. Though not directed explicitly at the article in question, this post will describe computation in this more general sense, and present a perspective on the brain/computer connection that makes the relation seem not so surprising.</p>
<p>To understand in what way the brain is a computer it’s of course instructive to first ask what makes anything a computer? Alan Turing may have provided a formal framework for digital computation in the 1930s but what we would call computers (albeit primitive) were envisioned long before then. The immediate examples that spring to mind are of course the difference and analytical engines of Charles Baggage, and the ‘programmable’ looms developed by Jacquard. These were devices that could be instructed to perform some task or calculation automatically. These machines off-load from ourselves the execution of a routine, generally but not necessarily sequential, set of tasks, and also may perform calculations for us. Critically, interpretting the machine’s behaviour in terms of elements within a set of tasks, or components of a calculation, requires that we ascribe to the machine a correspondance between its physical state and components of the task or calculation being performed. The abacus only counts if we correspond left and right beads with counted and uncounted units.</p>
<p>Thus <em>representation</em> is a core component of what makes something a computer. Indeed, a definition (though debated, as with any philosophical topic) of a computer is a physical system whose states can be put in to a reasonable correspondence with variables which perform a calculation of interest. Notice that such a definition allows for computation to be either analog or digital – a sundial acts as a simple computer. Computers today (as in laptops, PCs, mobile phones, etc), are such exceptionally powerful devices in terms of the breadth and speed with which they may perform myriad calculations of interest to us that it can seem hard to imagine how any other machine could reasonably be called a computer also. But the essential property that makes even the most powerful of servers a computer is exactly the same as the property that makes a sundial a computer – its capacity to represent and manipulate quantities of interest.</p>
<p>Given this general definition of computation, it may at least seem less surprising that the brain is an organ capable of computation. But we’re not done with our argument yet, we just have argued against the notion that computers need to be digital, serial, and run on electricity.</p>
<p>An often offered explanation for the relation between brains and computers is that our understanding of brains is often compared to the popular technology of the day. Thus in the 1600s mechanical analogies were used to understand the body’s function – Descartes envisioned pulleys and gears determining our behavior. Following the dynamical revolution of Newton (and Leibniz), cognition was viewed as a dynamical process: in terms of forces pushing and pulling our ego in conflicting direction. Finally, the digital computer last century has spurred the most recent set of comparisons. However, I would like to argue that, by looking at the history of computation, there is a more fundamental relation between computers and cognition then merely a metaphor in terms of ‘the technology of the day’. Unlike mechanical or dynamical analogies previously, the history of computation itself reveals itself as a kind of abstracted form of reasoning. If this is true, then almost by definition, cognition <em>must</em> have a computational component, and brains, equally, <em>must</em> be implementations of computers, when suitably generally defined.</p>
<p>Thus the relation between brains, minds and computers dates back at least to the 30s and 40s of last century, but also in a sense much earlier. Starting with Frege, Boole, and even Leibniz, philosophers have sought after formal systems capable of expressing thought and formal rules of reasoning. Frege’s formal system presented in his Begriffsschrift and Leibniz’s notion of a ‘calculus ratiocinator’, for instance. We can look at quotes from Hobbes and Leibniz:</p>
<p>“By reasoning, I understand computation. And to compute is to collect the sum of many things added together at the same time, or to know the remainder when one thing has been taken from another.” — Hobbes 1655</p>
<p>and</p>
<p>“The only way to rectify our reasonings is to make them as tangible as those of the Mathematicians, so that we can find our error at a glance, and when there are disputes among persons, we can simply say: Let us calculate, without further ado, to see who is right.” — Leibniz 1685</p>
<p>as evidence this view that computation is viewed as a type of mechanical reasoning.</p>
<p>The desire to make mathematical reasoning a purely algorithmic, or formal, process lead ultimately to Hilbert’s formalist program, and to Turing’s formulation of an ideal, mechanical, rule-following computer. Though ultimately Turing’s universal machines were physically realized as actual computing devices, originally they were devised purely as theoretical tools, models of mechanical reasoning to be used in proofs of statements in metamathematics. It is helpful to note that in the 1930s a computer referred to a person performing calculations, and that Turing’s original paper described a machine having a finite number of ‘states of mind’ – finite due to our own limited mental capacities. Starting with McCulloch and Pitts, Turing machines were envisioned as a kind of model of the mind. Indeed, his eponymous machines provided the basis for early functionalist philosophies of mind, and they still provide the basis for contemporary theories in cognitive science – the dominant view being that cognition is a type of computation. Turing maintained a strong interest in the relation between computers and the mind throughout his life.</p>
<p>Conversely, the other key figure in the founding of computer science, John von Neumann, also held a deep interest in the brain. In the 1940s, as part of Weiner’s cybernetics school, von Neumann engaged in much discussion about the relation between humans and machines, which lead to the brain being used very loosely as a model for the computers he was involved in designing. Von Neumann’s ‘First Draft of a Report on the EDVAC’, still the template for most computers in use today, makes reference to ‘organs’ of the computer, and discusses similarities and differences between the logical units of transistors and neurons. Later von Neumann, realizing the immense structural and functional complexity of the brain, moved away from thinking of modeling the brain so literally with a computer, and instead advocated using computers to numerically simulate some elements of the brain’s function. Though a gross charicature of their views, Turing and von Neumann serve to neatly represent the two elements of the brain-computer relation that computational neuroscience explores today – computers as models for cognitive processes and computers as tools to simulate the brain.</p>
<p>Given both the modern and early founders of computer science were so interested in reasoning and the brain, it is no surprise that we now find computers and brains intimately related – computation being a used as a model of a sort of formal reasoning. If mental states are computational states then they must have a physical substrate in the brain somewhere – thus brain states must also act as computational states. The connection is almost baked into the definitions.</p>Ben Lansdellben dot lansdell at gmail dot comDoing the rounds a while was an article posted on Aeon about how the brain is not a computer (here). How there is a fundamental difference between computers and brains in their structure, function and purpose. While it may be true that the brain does not function in the same way the laptop in front of me functions – processing bits of information in a predominantly serial fashion, with separated memory and processing components – this does not mean that the brain is not a computer in a more general sense. Though not directed explicitly at the article in question, this post will describe computation in this more general sense, and present a perspective on the brain/computer connection that makes the relation seem not so surprising.Introduction to statistical causal inference2018-04-03T00:00:00+00:002018-04-03T00:00:00+00:00//benlansdell.github.io/statistics/causalinference<div>
A brief overview of how causal inference and causal effects are formalized.
Say we observe a negative relationship between number of apples eaten
per day and heart disease. Does this relationship mean that apples are
protective against disease? Maybe. It is well known that correlation
does not imply causation. Perhaps in this case number of apples eaten
per day correlates with general diet, or general fitness, which instead
are the cause of lower heart disease. Such factors are a source of
confounding. How do we distinguish between these possibilities? A
statistician answers these causal inference questions in two ways: by
considering counterfactuals and interventions.
A counterfactual is simply a potential event that did not occur. A given
patient either does or does not receive the treatment on a given trial.
Whichever event does not occur is the counterfactual. Under a
counterfactual account of causality to claim that a proposed treatment
causes disease remission is to claim that had the patient not received
the treatment then the disease outcome would be different (greater).
Interventionist accounts are similar but focus on the notion of
manipulability. Here to claim that one variable causes another is to
claim that if through intervention one variable is forced to a given
state then a change in the other variable will be observed. Here the
notion of intervention is treated as a primitive and causal
relationships are derived from that.
Thus, had a given patient *not* had so many apples per day, would their
health be worse? And, if a patient was *forced* to eat many apples per
day, would their health be better? Here we focus on frameworks that
attempt to answer these questions in the presence of confounding. The
basic idea is that if we do observe all the factors we reasonably
consider to be confounding the estimate then we can correct for this.
Learning causal relationships
=============================
Randomized controlled trials (RCTs) are the gold standard for causal
inference. The idea simply being that if assignment to a treatment group
is randomized then the distribution of covariates in the control and
treatment groups will be identical, and therefore any difference in
outcome between the control and treatment groups can then only be
attributed to the fact that one group received a treatment while the
other did not.
However, sometimes RCTs are difficult, expensive, or unethical to
perform. This motivates considering when causal relationships can be
inferred from observational data alone. In the absence of randomization,
receiving treatment may be correlated with many other factors which
could also impact the outcome. What are conditions in which the effects
of confounding can be mitigated?
Counterfactual outcomes are not observed for individual patients – they
either receive a treatment or do not. This is known as the fundamental
problem of causal inference. As a result often we need to (or in fact
want to) consider aggregate causal effects estimated over a population.
This has two consequences for analysis.
The first is that in considering causal relationships in this aggregate
sense, the timing of pairs of events is often unspecified, vaguely
defined, or implicit in how data is collected. By losing this timing
information it is harder to analyze cases of mutual causation. Thus the
assumption made here is that one variable is the cause of another, or
vice versa, or not at all – there is a directedness to the relationship
over the time window in which observations are made. It addition to
excluding mutual causation from consideration, it is simplest to further
exclude cycles, or causal chains (e.g. $A \to B \to C \to A$). The
second consequence is that, by considering a population of
subjects/events, it becomes more necessary to allow for probabilistic
causal relationships, in which one variable’s occurrence affects
another’s probability of occurring and the relationship need in no way
be deterministic. These considerations motivate summarizing causal
relationships between a set of variables using directed acyclic graphs
(DAGs), and using a probabilistic framework.
Counterfactuals: the causal effect as difference in potential outcomes
======================================================================
Measuring causal effects in terms of counterfactuals is a relatively old
idea (as far as statistics goes), dating back to 1923 from work of
Neyman. The Neyman-Rubin causal model provides a framework for reasoning
about causal effects with counterfactuals. In a simple setting, the
model considers two *potential outcomes*: an outcome when a subject does
receive a treatment, $Y(1)$, and an outcome when a subject does not
receive a treatment, $Y(0)$ (i.e. a control subject). For a given
subject, $i$, the *causal effect* is the difference in potential
outcomes:
$$
\begin{align}E_i = Y_i(1)-Y_i(0).\end{align}
$$
If we let $W_i$ be a treatment random variable then assuming consistency between potential and
observed outcome, $Y_i$, we have:
$$\begin{align}\label{eq:consistent}
Y_i = W_iY_i(0) + (1-W_i)Y_i(1).\end{align}$$
As an aside, note that the potential outcomes $Y(i)$ are treated as
kinds of hypothetical random variables. In a sense neither is observed,
and they are only related to observation through the assumption that
holds. This is a somewhat subtle point that is perhaps not well
reflected in the notation. Equations in causal models can have quite
different interpretations to standard statistical models, despite having
similar notation, which is important to be aware of.
Per the *fundamental problem of causal inference*, only one of these
potential outcomes is ever observed. To get around this, causal effects
can be measured over a population of subjects, some of which receive the
treatment and some of which do not. Over a population we can consider
the *average causal effect*:
$$\begin{align}\tau = \mathbb{E}(Y_I(1)-Y_I(0)).\end{align}$$
If $W_i$ is assigned to each subject at random then $\tau$ can be
computed directly from the treatment and control subpopulation means. In
randomized cases, $W_i$ is independent from the potential outcomes. If
$W_i$ were not independent from the potential outcomes then the measured
causal effect (difference in means) could simply be a result of this
correlation.
Causal assumptions for identifiability
--------------------------------------
Being able to measure a causal effect in an unbiased (unconfounded) way
means the effect is *identifiable*. Within this counterfactual
framework, this linking of potential outcomes to causal effects relies
on four *causal assumptions*. Some of these have been alluded to above.
They are:
1. (**SUTVA**) Stable Unit Treatment Value Assumption. This means:
- There is no interference in treatments – one subject receiving
treatment does not affect others’ treatment.
- There is only one form of treatment.
2. (**Consistency**) This assumption links the hypothetical potential
outcomes to observed data. If we assume consistency then we are
assuming:
$$\begin{align}Y_i = W_iY_i(0) + (1-W_i)Y_i(1),\end{align}$$ as discussed above.
3. (**No unmeasured confounders/ignorability**) The treatment
assignment is independent of the potential outcomes:
$$\begin{align}Y(1),Y(0) {\mathrel{\text{$\perp\mkern-10mu\perp$}}}W.\end{align}$$
In most cases of interest both the outcome and treatment variable
are related to a set of observed covariates, $X$. Causal inference
then requires:
$$\begin{align}Y(1),Y(0) {\mathrel{\text{$\perp\mkern-10mu\perp$}}}W | X.\end{align}$$
In RCTs this assumption may be reasonable. This says that the
distribution of potential outcomes $(Y(1), Y(0))$ is the same across
treatment levels $W$, conditioned on $X$. In observational settings
often this is the primary assumption that is a road block
to identifiability.
Another way to understand this is as follows. We want to relate
observed quantities to hypothetical potential outcomes. We can do
this if we assume ignorability: $$\begin{aligned}
\mathbb{E}(Y|W=1)-\mathbb{E}(Y|W=0) &= \mathbb{E}(WY(1)+(1-W)Y(0)|W=1)-\mathbb{E}(WY(1)+(1-W)Y(0)|W=0)\\
&= \mathbb{E}(Y(1)|W=1)-\mathbb{E}(Y(0)|W=0)\\
\text{(ignorability)}\quad &= \mathbb{E}(Y(1) - Y(0)))\\
&= \tau\end{aligned}$$
4. (**Positivity**) Additionally, causal inference requires a non-zero
probability of assignment to a treatment group for all subjects:
$$\begin{align}0 < \mathbb{P}(W_i = 1|X_i = x) < 1, \quad \forall x.\end{align}$$ This is
known as the *positivity*, or overlap, assumption.
Simply, a causal effect cannot be measured if no subjects receive
the treatment, or they all do.
Directed acyclic graphs and probability distributions
=====================================================
In a sense the conditional independence between treatment and potential
outcome is the main assumption that requires analysis in the above set
of assumptions. This analysis can be aided by encoding our assumptions
about the relations between different variables in a graph. This section
defines and describes the behavior of these graphs. The following
section contains criteria that can be used to identify sets of variables
that are sufficient to act as controls, that remove the effect of
confounding and hence that satisfy ignorability. These models are types
of graphical models, sometimes known as *Bayesian networks*, and were
first developed by Pearl in the 1980s.
Here we will consider a set of random variables $\mathcal{X}$ as nodes
on a directed acyclic graph $\mathcal{G}$. Let this graph have edges
$\mathcal{E}$ that represent relations between the variables.
Ignorability requires conditional independence of the outcome from the
treatment variable, so here we will let the directed edges encode
conditional independence assumptions. (A *causal Bayesian network* has
additional semantics that are discussed below. For the
moment the directed edges only encode information about conditional
independence.)
First note that the DAG imposes an ordering on the variables
$\mathcal{X}$, from which we can talk about a node’s parents, children,
ancestors or descendants. Note also that any multivariate distribution
can be decomposed into a product of conditional probabilities for any
ordering of the variables:
$$\begin{align}P(X) = \prod_{j=1}^N P(X_j|\{X_k\}_{k>j}).\end{align}$$
Given this, if we assume that the variables are ordered in a way that
respects the ordering of the DAG, then we will say $\mathcal{X}$ is a
Bayesian network with respect to $\mathcal{G}$ if the joint distribution
over variables $\mathcal{X}$ factors according to:
$$\begin{align}P(X) = \prod_{j=1}^N P(X_j|\text{Pa}(X_j)),\end{align}$$ where $\text{Pa}(X_j)$
is the parents of node $X_j$. That is, each node $X_j$ is conditionally
independent of its non-descendants given its parents:
$$\begin{align}P(X_j|\{X_k\}_{k>j}) = P(X_j|\text{Pa}(X_j)).\end{align}$$ This is the *Markov
condition*, or Markov assumption, for a Bayesian network. A node is
conditionally independent of the entire network given its *Markov
blanket* – its parents, its children, and its children’s other parents.
Often also invoked is the *faithfulness condition*, which is the
condition that the conditional independencies implied by the graph are
the only conditional independencies in the distribution. E.g. assuming
faithfulness in the graph $A \to B$ says that there is in fact a
dependence between $A$ and $B$.
Some types of graphs
--------------------
Some properties of a Bayesian network can be inferred graphically. For
instance three basic components of DAGs are:
1. Chain: $A \to B \to C$
2. Fork: $A \leftarrow B \to C$
3. Collider (inverted fork): $A \to B \leftarrow C$
These graphs behave differently when conditioning on parts of them.
Compare the fork and the inverted fork.
- For the fork, $A$ and $C$ are dependent. Yet when conditioned on
$B$, $A$ and $C$ become independent.
- The converse is true for the inverted fork. Without conditioning,
$A$ and $B$ are independent. Yet when conditioned on $B$, $A$ and
$C$ become dependent. This may seem a little counter-intuitive. An
example of this phenomenon is if $B$ is determined through tossing
two independent coins, $A$ and $C$. If $B$ is determined as
$$\begin{align}B = \begin{cases}
1, \quad A=H, C = H;\\
0, \quad \text{else}
\end{cases}\end{align}$$ By itself, knowing $A$ tells you nothing about $C$.
But knowing $B$ and $A$ now tells you something about $C$.
Note that the fork and the chain have the same behavior:
- For the fork, $A$ and $C$ are dependent. Yet when conditioned on
$B$, $A$ and $C$ become independent.
- For the chain, $A$ and $C$ are dependent. Yet when conditioned on
$B$, $A$ and $C$ become independent.
d-separation
------------
For more complicated graphs, are a given set of variables sufficient
controls to render two nodes conditionally independent? Here the notion
of *d-separation* is useful.
The d stands for dependence. Let $P$ be a path from node $u$ to $v$. A
path is a loop-free, undirected (i.e. all edge directions are ignored)
path between two nodes. Then $P$ is said to be d-separated by a set of
nodes $Z$ if any of the following conditions holds:
- $P$ contains a directed chain such that the middle node $m$ is in
$Z$, or
- $P$ contains a fork, $u \cdots \leftarrow m \to \cdots v$, such
that the middle node m is in Z, or
- $P$ contains an inverted fork (or collider),
$u \cdots \to m \leftarrow \cdots v$, such that the middle node $m$
is *not* in $Z$ and no descendant of $m$ is in $Z$.
Nodes $u$ and $v$ are said to be d-separated by $Z$ if all paths between
them are d-separated. If $u$ and $v$ are not d-separated, they are
called d-connected.
We have the result that $X_u$ and $X_v$ being d-separated by $Z$ tells
us that $X_u$ and $X_v$ are conditionally independent given $Z$.
Markov equivalence classes
--------------------------
Note that a DAG may prescribe a factorization of the probability
distribution, but the converse is not true. That is, knowing a
factorization of the joint distribution does not always imply a unique
DAG. Instead it prescribes a *Markov equivalence class* of DAGs. This
means that if we want to think of the directed edges as representing
causal relationships then knowing a joint distribution factorization
does not always provide a unique graph of causal relationships. This
limits what we can learn about causal relationships from a joint
(observational) distribution alone.
Two graphs are Markov equivalent iff they share the same conditional
independencies. Equally, they are Markov equivalent iff they have the
same d-separations. That is, if $u$ and $v$ are d-separated by $C$ in
$\mathcal{G}_1$ then they are d-separated by $C$ in $\mathcal{G}_2$, and
vice versa. Some examples of DAGs that are Markov equivalent are shown
in Figure \[fig:dags\].
![Examples of DAGs in the same Markov equivalence class.<span data-label="fig:dags"></span>](./../images/dags.svg)
In fact a simple graphical rule tells us if two DAGs are in the same
Markov equivalence class. The *skeleton* of a network is the undirected
graph. Two DAGs are in the same equivalence class (observationally
equivalent) if they have the same skeleton and the same set of
‘v-structures’ – the same set of two converging arrows whose tails are
not connected by an arrow.
Controlling for confounders
===========================
Now we know some of the behavior of Bayesian networks we can return to
the question of identifying variables that can be controlled for to
remove confounding. This means we want to identify variables $X$ such
that ignorability holds:
$$\begin{align}Y(1),Y(0) {\mathrel{\text{$\perp\mkern-10mu\perp$}}}W | X.\end{align}$$
Note that the observed outcome is of the form $Y = W Y(1) + (1-W)Y(0)$,
which induces a conditional dependence between $W$ and $Y$ – the
corresponding DAG will have a directed edge from $W$ to $Y$.
Ignorability requires essentially that any *other* paths from $W$ to $Y$
are blocked (i.e. controlled for, conditioned on). Which choices of $X$
achieve this? Three such criteria are identified below, stated without
proof. An example of each is shown in Figure \[fig:criteria\].
Backdoor criterion
------------------
If a set of variables $X$ satisfy the following conditions:
1. $X$ blocks every path from $W$ to $Y$ that has an arrow into $W$
(blocks the back door), and
2. No node in $X$ is a descendant of $W$.
then $X$ satisfies the backdoor criterion with respect to nodes $W$ and
$Y$.
Disjunctive cause criterion
---------------------------
Sometimes simpler than using the backdoor criterion, which can involve
analyzing the entire DAG is the disjunctive cause criterion. It is
simply:
- Control for all parents of the treatment variable, the effect
variable (that are not descendants of the treatment), or both.
Sometimes this is an easier set to identify than other (potentially
smaller) sets that satisfy the backdoor criterion.
Frontdoor criterion
-------------------
If a set of variables $Z$ satisfy the following conditions:
1. $Z$ blocks all directed paths from $X_i$ to $X_j$, and
2. there is no backdoor path from $X_i$ to $Z$, and
3. all backdoor paths from $Z$ to $X_j$ are blocked by $X_i$
then $Z$ satisfies the frontdoor criterion with respect to nodes $X_i$
and $X_j$.
![Three criteria through which conditioning on $Z$ will render the
effect of $X$ on $Y$ identifiable.<span data-label="fig:criteria"></span>](../../images/dags_criteria.svg)
Some common methods
===================
Once a set of variables to control for has been identified, how do we
actually use this knowledge to identify causal effects? In theory, if we
observe controls $X$ then we can measure the causal effect from:
$$\begin{align}\tau = \mathbb{E}(\mathbb{E}(Y|W=1,X)-\mathbb{E}(Y|W=0,X)).\end{align}$$
In practice however this requires a lot of data to get reliable
estimates of each conditional expectation. In biomedical/social science
settings this is often an issue. Generally each conditional expectation
has to be estimated parametrically to capture the dependence on $X$.
This introduces bias through choice of model, etc. Thus methods that can
estimate causal effects without this modeling are attractive. A way of
doing this is to effectively match the confound distribution $X$ between
the control and treatment groups. Thereby making treatment independent
of the covariates, and the data more like what is produced in a
randomized control trial. This balancing of distributions among control
and treatment groups is achieved through sampling subjects in different
ways.
Matching
--------
The basic idea of matching is as follows. For each condition $W= 1$ and
$W=0$ there are only a finite number of samples:
$$\begin{align}\{y_i^{w=0}, x_i^{w=0}\}_{i=1}^{I_0} \text{ and } \{y_i^{w=1}, x_i^{w=1}\}_{i=1}^{I_1}.\end{align}$$
Matching simply pairs one sample in the treatment group with one sample
in the control group whose control covariates are close:
$$\begin{align}(y_i^{w=0}, x_i^{w=0})\leftrightarrow (y_j^{w=1}, x_j^{w=1}), \quad x_i^{w=0}\sim x_j^{w=1}.\end{align}$$
Since between treatment groups $X$ have roughly the same distribution,
this dependence does not need to be modeled. This allows the above
causal effect expectation to be approximated.
Choices must be made about the metric that is used to decide when two
points are similar. And choices must be made about how to deal with
different treatment and control population sizes. One possibility is to
discard all samples for which no match is made. Another possibility is
to match one sample in the treatment group to more than one sample in
the control group.
A common way is to match on the treatment group. This then estimates
what is known as the *causal effect of treatment on the treated*, often
a quantity of interest. If we let $C(i)$ represent the sample index in
the control population that is matched to sample $i$ in the treatment
population then the causal effect is estimated from:
$$\begin{align}\tau \approx \frac{1}{I_1}\sum_{i=1}^{I_1} y_i^{w=1} - y_{C(i)}^{w=0}.\end{align}$$
Matching can be performed on all covariates, or just covariates that are
identified as confounders, according to the backdoor or other criterion.
Note that matching does not remove the need for ignorability –
unmeasured confounders can still affect the analysis, thus $X$ still
must satisfy the backdoor criteria.
Propensity score matching
-------------------------
Matching directly on controls $X$ can be difficult if $X$ is
high-dimensional. Instead, we can match on what is called the propensity
score, which is the probability of being treated given a set of
controls: $$\begin{align}\pi(X) = P(W = 1| X).\end{align}$$
Matching on $\pi(X)$ has the same effect as matching on $X$ directly.
This is because subjects at the same propensity level have, by
definition, the same probability of being assigned to the treatment
group. Thus, for these subjects, treatment assignment is randomized
(independent of $X$). In this way the distribution of $X$ in treatment
and control groups are made to be the same.
The propensity score is known, by definition, in randomized control
trials. It has to be estimated in observational studies. But since it
only involves observed data $X$ and $W$ this is straightforward. For
example, one can use logistic regression.
Again, propensity score matching still requires the ignorability
assumption with controls $X$. Without it, even if the distribution of
$X$ is balanced between control and treatment groups, unobserved
confounders can still be different amongst control and treatment.
Inverse probability of treatment weighting
------------------------------------------
Instead of matching on propensity score, which may discard some samples,
we can simply reweight each subject by the inverse of its probability of
receiving treatment – known as the inverse probability of treatment
weighting (IPTW). This matches one unit in a treatment group with a
certain number of ‘pseudo-units’ in the control group at a rate
proportional to the relative probability of receiving treatment at a
given level in $X$. In this way balance is achieved across levels.
This is a type of importance sampling.
Causal Bayesian networks {#sec:cbn}
========================
This is the framework developed most significantly by Pearl. A causal model is a Bayesian network along with a
mechanism to determine how the model will respond to intervention. Now,
rather than using the notion of potential outcomes and counterfactuals,
causal effects are measured as the result of intervention. In addition
to parents/children, we also think of the directed edges in the DAG as
representing causal relationships, meaning a node’s parents and children
are also its causes and effects.
The *causal Markov condition* is the condition that all nodes are
independent of their non-effects, given their direct causes. In the
event that the structure of a Bayesian network accurately depicts
causality, this is equivalent to the Markov condition. However, a
network may accurately embody the Markov condition without depicting
causality, in which case it should not be assumed to embody the causal
Markov condition.
Interventions and causal effects
--------------------------------
An intervention on a single variable is denoted ${\text{do}}(X_i = y)$.
Intervening on a variable removes the edges to that variable from its
parents and forces the variable to take on a specific value:
$$P(x_i|{\text{Pa}}_{X_i}=\mathbf{x_i}) = \delta(x_i = y)$$. The
interventional joint distribution, $P_{X_i=y}$, is then defined as:
$$\begin{align}P_{X_i=y}(\mathbf{x}) = \prod_{j\ne i}^N P(x_j | {\text{Pa}}_{X_j} = \mathbf{x}_j)\delta(x_i = y),\end{align}$$
also abbreviated to $P_{X_i}$. Expectations under interventions then
take the form:
$$\begin{align}\mathbb{E}(X_j|{\text{do}}(X_i = y)) = \int x_j P_{X_i=y}(x_j)\,dx_j = \mathbb{E}_{X_i=y}(X_j).\end{align}$$
Now, given the ability to intervene, the average causal effect between
an outcome variable $X_j$ and a binary variable $X_i$ can be defined as:
$$\begin{align}\tau = \mathbb{E}(X_j|{\text{do}}(X_i = 1)) - \mathbb{E}(X_j|{\text{do}}(X_i = 0)).\end{align}$$
In general, the ‘do’ conditional is different to standard probabilistic
conditioning. However criteria exist under which the interventional
conditional distribution coincides with the probabilistic conditional
distribution. The causal effect from node $X_i$ to $X_j$ can be inferred
for conditional distributions that satisfy these criteria. These are
actually the same criteria identified above in the counterfactual
framework when searching for controls that provide ignorability. The
interventional and counterfactual frameworks thus are compatible with
one another.
For instance, if $S_{ij}$ satisfy the backdoor criteria with respect to
$X_i\to X_j$ then we can relate the interventional and observational
expectations as follows: $$\begin{aligned}
\nonumber \mathbb{E}(X_j|{\text{do}}(X_i = y)) &= \int x_j P_{X_i = y}(x_j)\,dx_j\\
\nonumber &= \int\int x_j P_{X_i = y}(x_j|\mathbf{s}_{ij})P_{X_i = y}(\mathbf{s}_{ij})\,dx_j d\mathbf{s}_{ij}\\
\nonumber &= \int\int x_j P(x_j|\mathbf{s}_{ij}, X_i = y)P(\mathbf{s}_{ij})\,dx_j d\mathbf{s}_{ij} \\
\label{eq:doce}&= \mathbb{E}\left(\mathbb{E}(X_j|\mathbf{S}_{ij}, X_i = y)\right),\end{aligned}$$
from which a causal effect can be measured.
Structural equation models
==========================
The above frameworks are non-parametric, dealing simply with
factorizations of joint distributions. The parametric form of a causal
Bayesian network is the structural equation model (SEM). Each node is
described by: $$\begin{align}X_j = f_j(\text{Pa}(X_j), \epsilon_j; \theta_j),\end{align}$$ for
some independent noise variable $\epsilon_j$, and parameters $\theta_j$.
Note that the equality here is of a different nature to an algebraic
equality. It conveys assignment rather than comparison. (Similar to the
difference between = and == in programming languages.) Some authors use
$\leftarrow$ instead of = to communicate this difference. This means
that structural equation models have an invariance property that
standard statistical models do not: the SEM is robust to intervention.
The model should describe the data equally well regardless of whether it
comes from observation or interventional experiments.
Some further reading
====================
An overview of the counterfactual framework can be found in the short
Coursera course. The interventionist framework of Pearl is described in
his influential 2000 book. A more modern treatment, based on structural
equation models, can be found in Peters et al 2017.
- “A Crash Course in Causality: Inferring Causal Effects from
Observational Data” Coursera course. By Jason Roy.
[www.coursera.org/learn/crash-course-in-causality/](www.coursera.org/learn/crash-course-in-causality/)
- “Causality: Models, Reasoning and Inference” Judea Pearl, 2000.
- “Elements of Causal Inference: Foundations and Learning Algorithms”
Jonas Peters, Dominik Janzing and Bernhard Schölkopf, 2017.
</div>Ben Lansdellben dot lansdell at gmail dot comMathJax, Jekyll and github pages2016-06-27T00:00:00+00:002016-06-27T00:00:00+00:00//benlansdell.github.io/computing/mathjax<p>Integrating MathJax with Jekyll is a very convenient way of typesetting mathematics in a blog hosted on github pages. There are a few guides online, which were (almost) helpful in acheiving this on a github hosted site. The steps, as of September 2016, are:</p>
<p>Ensure the markdown engine is set to <code class="language-plaintext highlighter-rouge">kramdown</code> in <code class="language-plaintext highlighter-rouge">_config.yml</code>. This is now the <a href="https://help.github.com/articles/updating-your-markdown-processor-to-kramdown/">only supported markdown processor</a> on github pages, so this should be set anyway.</p>
<p>Include a new file in <code class="language-plaintext highlighter-rouge">_includes</code> named <code class="language-plaintext highlighter-rouge">_mathjax_support.html</code> (a clever idea from <a href="http://haixing-hu.github.io/programming/2013/09/20/how-to-use-mathjax-in-jekyll-generated-github-pages/">here</a>):</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code><script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
equationNumbers: {
autoNumber: "AMS"
}
},
tex2jax: {
inlineMath: [ ['$', '$'] ],
displayMath: [ ['$$', '$$'] ],
processEscapes: true,
}
});
MathJax.Hub.Register.MessageHook("Math Processing Error",function (message) {
alert("Math Processing Error: "+message[1]);
});
MathJax.Hub.Register.MessageHook("TeX Jax - parse error",function (message) {
alert("Math Processing Error: "+message[1]);
});
</script>
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
</code></pre></div></div>
<p>The bottom two hooks alert the user/writer about math and tex errors.</p>
<p>Importantly, in contrast to older guides online, note the https in the MathJax CDN. Unencrypted access to the CDN is a security risk and now will either not render in some browsers (didn’t work in Chrome for me), or will issue warnings in other browsers (Firefox). See the MathJax <a href="http://docs.mathjax.org/en/latest/start.html#secure-access-to-the-cdn">documentation</a> for more information.</p>
<p>Next, include in the <code class="language-plaintext highlighter-rouge"><head></code> of <code class="language-plaintext highlighter-rouge">_layouts/default.html</code>:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>{% if page.use_math %}
{% include mathjax_support.html %}
{% endif %}
</code></pre></div></div>
<p>Now to include $\LaTeX$ in a post you just need set the variable <code class="language-plaintext highlighter-rouge">use_math: true</code> in the YAML front-matter of the page/post! Enclose inline formulas in <code class="language-plaintext highlighter-rouge">$</code>s and display formulas in <code class="language-plaintext highlighter-rouge">$$</code>s. For instance,</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$$
K(a,b) = \int \mathcal{D}x(t) \exp(2\pi i S[x]/\hbar)
$$
</code></pre></div></div>
<p>produces:</p>
<div>
$$
K(a,b) = \int \mathcal{D}x(t) \exp(2\pi i S[x]/\hbar)
$$
</div>
<h2 id="alignment">Alignment</h2>
<p>Note that any equations requiring alignment (use of ampersand &) need some care. The solution I found was to wrap any of these elements in <div>’s.</p>
<h2 id="changing-typeset-fontsize">Changing typeset fontsize</h2>
<p>Add the following to <code class="language-plaintext highlighter-rouge">MathJax.Hub.Config</code>:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>CommonHTML: {
scale: 85
}
</code></pre></div></div>
<h2 id="some-references">Some references:</h2>
<ul>
<li>http://cwoebker.com/posts/latex-math-magic – no longer seems to work</li>
<li>http://haixing-hu.github.io/programming/2013/09/20/how-to-use-mathjax-in-jekyll-generated-github-pages/</li>
<li>MathJax guide: http://docs.mathjax.org/en/latest/tex.html</li>
<li>MathJax details: http://docs.mathjax.org/en/latest/advanced/model.html</li>
</ul>Ben Lansdellben dot lansdell at gmail dot comIntegrating MathJax with Jekyll is a very convenient way of typesetting mathematics in a blog hosted on github pages. There are a few guides online, which were (almost) helpful in acheiving this on a github hosted site. The steps, as of September 2016, are:On the relation between maximum likelihood and KL divergence2016-06-26T00:00:00+00:002016-06-26T00:00:00+00:00//benlansdell.github.io/statistics/likelihood<p>In this post I describe some of the theory of maximum likelihood estimation (MLE), highlighting its relation to information theory. In a later post I will develop the theory of maximum entropy models, also drawing connections to information theory, hoping to clarify the relation between MLE and MaxEnt.</p>
<p>Maximum likelihood was developed and advocated by many figures throughout the history of mathematics (see [1] for a nice overview). In a sense it was first considered in a significant way by Lagrange, but it was also considered by Bernoulli, Laplace, and Gauss, among others. Indeed, what was known as the ‘Gaussian method’ involved maximum aposteriori estimation of a model with normal distributed errors and a uniform prior, resulting in what is now known as the method of least squares. However, its theory and use was advanced most strongly by Fisher in the 1920s and 30s. Fisher worked for many years to demonstrate conditions needed for both the consistency of MLE and efficiency. While his later results have stood up to scrutiny, the theory, as it stands, does not possess the quite generality he sought after. Nonetheless, it remains a cornerstone of contemporary statistics.</p>
<h2 id="maximum-likelihood-estimation">Maximum likelihood estimation</h2>
<p>Much of statistics relies on identifying models of data that are, in some sense, close to our observations. Indeed, in many cases it seems sensible that we seek models that are the closest to our observations. Maximum likelihood provides one principle by which we may identify theseclosest distributions. It has many appealing properties that make it an appropriate measure, and is a broadly applicable method. As we will see its simplicity is somewhat deceiving.</p>
<p>The theory is easiest to describe in a discrete setting, which we will address first. Let</p>
<div>
$$
\begin{equation}
x = (x_1, x_2, \cdots, x_N)
\end{equation}
$$
describe $N$ observations drawn from a discrete probability distribution. Each draw $x_n\in\mathcal{X}$ is taken from an alphabet of $M$ characters, $\mathcal{X}=(a_1, \dots, a_M)$. Let $p_m$ denote the probability of drawing character $m$ in any one draw, and let $f_m$ denote the frequency of character $m$ is observed in the $N$ draws. Note that we're just describing a multinomial distribution having $M$ parameters $p_m$.
Given our observations, how should we estimate the multinomial parameters $\mathbf{p}$? The principle of maximum likelihood states simply that we take parameters that result in our observations having highest probability, when compared with all other possible choices of parameters. If we assume that each draw is independently and identically distributed (i.i.d.) then this is
<div>
$$
\begin{align}
\hat{\mathbf{p}}_{MLE} & = \text{argmax}_{p\in \mathcal{P}} \prod_{n=1}^Np_{x_n}\\
& = \text{argmax}_{p\in\mathcal{P}}\log\left(\prod_{n=1}^Np_{x_n} \right) \\
& =\text{argmax}_{p\in\mathcal{P}}\sum_{n=1}^N\log \left( p_{x_n} \right) \\
& =\text{argmax}_{p\in\mathcal{P}}\sum_{m=1}^M f_m \log \left( p_m \right)
\end{align}
$$
</div>
For many reasons, some of which will become clear here, expressing the maximization problem in terms of logarithms is the natural choice, so the last line above is one we will be optimizing. (As a brief aside, note the step taken to reach the last line appears a trivial manipulation, but if we were to write out what was happening in a general probability space, it is roughly analogous to the pushforward change of variables:
$$
\begin{align*}
\int_\mathbb{R} \log (p(x)) dF(x) = \int_\Omega \log(p(X(\omega)) d\mu(\omega)\end{align*}
$$
we make when shifting between expectations in terms of a measure $\mu$ and a distribution function $F$. The LHS being given by a Lebesgue-Stieltjes integral, the RHS by a Lebesgue integral.)
The problem is constrained by the fact that $\sum q_m = 1$ and $q_m\ge 0 \forall m$. This constrained optimization problem can be solved using Lagrange multipliers. Recall this involves augmenting our objective function with our constraints
$$
\begin{equation}
\text{argmax}_{p\in\mathcal{P}} \sum_{m=1}^M f_m \log \left(p_{x_n}\right) - \lambda (\sum_{m=1}^Mq_m - 1) + \sum_{m=1}^M\mu_m p_m = \text{argmax}_{p\in\mathcal{P}} \mathcal{\tilde{L}}(\mathbf{p}, \mathbf{f})\end{equation}
$$
We set the partial derivative of the Lagrangian $\mathcal{\tilde{L}}$ taken with respect to $p_m$ to zero to obtain
$$\begin{equation}
p_m = \frac{1}{\lambda + \mu_m} f_m
\end{equation}$$
We find that the optimal occurs at, not surprisingly, the empirical estimates for the mean. Thus we have that the MLE estimates for our multinomial distribution are maximized at the empirical distribution.
## KL-divergence
I mentioned earlier that we would like some measure of closeness, and would like to find distributions that are 'close' our observations. What measure of closeness have we just minimized? In the discrete case, we have just minimized the relative entropy, or Kullback-Liebler divergence between the empirical distribution and the model.
Recall the empirical distribution is
$$\begin{equation}
\hat{q}_m = \frac{\sum_{n=1}^N\mathbf{I}}{\|\mathbf{f}\|_1} = \frac{f_m}{N}
\end{equation}$$
so that:
<div>
$$
\begin{align*}
\hat{\mathbf{p}}_{MLE}
& = \text{argmax}_{\mathbf{p}\in\mathcal{P}} \sum_{m=1}^M f_m \log \left( {p_m} \right) \\
& = \text{argmin}_{\mathbf{p}\in\mathcal{P}} \sum_{m=1}^M \hat{q}_m \log \left( \hat{q}_m \right) - \hat{q}_m \log \left( {p_m} \right) \\
& = \text{argmin}_{\mathbf{p}\in\mathcal{P}} \sum_{m=1}^M \hat{q}_m \log \left( \frac{\hat{q}_m}{p_m} \right) \\
& = \text{argmin}_{\mathbf{p}\in\mathcal{P}} D_{KL}( \mathbf{q} | \mathbf{p}) \\
\end{align*}
$$
</div>
where we have taken as convention $0\log(0) = 0$. _Thus in the discrete case, at least, maximizing likelihood corresponds to minimizing the KL divergence._
We have discussed only the case where $\mathbf{p}$ is estimated non-parameterically. What if we instead have some probability model described by a parameter $\theta$? The optimization problem now becomes
<div>
$$
\begin{align}\hat{\theta}_{MLE} & = \text{argmax}_{\theta\in\Theta}\mathcal{L}(\theta|\mathbf{f})\\
& = \text{argmax}_{\theta\in\Theta}\sum_{m=1}^M f_m \log \left(p_m(\theta)\right)\\\end{align}
$$
</div>
which is typically found by solving $\frac{\partial}{\partial \theta}\mathcal{L}(\theta\|\mathbf{f}) = 0$. The result is the same however -- we minimize the difference between the empirical distribution and the parametric model.
In the continuous case things are not so straightforward. We try the same argument for a real-valued random variable, $N$ observations $X^n = \{x_1, \dots, x_N \}$, and a parametric model $f(x; \theta)$. If we denote by
<div>
$$\begin{equation}
p_D(x) = \frac{1}{N}\sum_{i=1}^{N}\delta(x-x_i)
\end{equation}$$
</div>
the 'empirical density', then trying the same argument gives:
<div>
$$
\begin{align*}
\hat{\theta}_{MLE}
& = \text{argmax}_{\theta} \sum_{i=1}^N \log \left( f(x_i;\theta) \right) \\
\text{(??)} \qquad & = \text{argmax}_{\theta} \int p_D(x) \log \left( {f(x;\theta)} \right) \,dx\\
\text{(??)} \qquad & = \text{argmin}_{\theta} \int p_D(x) \log \left( \frac{p_D(x)}{f(x;\theta)} \right) \,dx\\
& = \text{argmin}_{\theta} D_{KL}( p_D | f(\dot; \theta)) \\
\end{align*}
$$
</div>
However, the question marked lines don't quite make sense -- it's unclear what the $log p_D(x)$ is in a continuous setting. For such a line to make sense the empirical distribution would have to be absolutely continuous so that $p_D$ was actually a density.
## Consistency
That said, the intuition about MLE and min. $D_{KL}$ does carry through to the continuous setting in the following sense. Let the data be generated by a model given by $f(x; \theta^*)$ and let
$$\begin{equation}
M_N(\theta) = \frac{1}{N}\sum_{i=1}^N \log(f(x_i;\theta))
\end{equation}$$
denote the quantity we maximize under MLE. We note that this is an approximation to the expectation
$$\begin{equation}
M_N(\theta) \approx \mathbb{E}_{\theta^*} \log(f(X;\theta))
\end{equation}$$
and that, through the law of large numbers, this indeed converges to
$$\begin{equation}
\lim_{N\to\infty} M_N(\theta) =M(\theta) = \mathbb{E}_{\theta^*} \log(f(X;\theta)).
\end{equation}$$
But maximizing $M(\theta)$ is the same as minimizing $D_{KL}(f(\theta^*)\|f(\theta))$ since:
<div>
$$\begin{equation}
\max_{\theta} M(\theta) = \max_{\theta} \mathbb{E}_{\theta^*} \log \left(\frac{f(X;\theta)}{f(X;\theta^*)}\right) = \min_{\theta} D_{KL}(f(\theta^*)\|f(\theta))
\end{equation}$$
</div>
Note that since $D_{KL} \ge 0$ and $D_{KL}(f\|g) = 0 \iff f = g$ then, under regularity conditions not specified here, this result implies the consistency of the MLE -- that $\theta_N \to^{P} \theta^*$ as $N\to\infty$.
</div>
<h2 id="a-reference">A reference</h2>
<ol>
<li>“The Epic Story of Maximum Likelihood” Stephen M. Stigler. 2007.</li>
</ol>Ben Lansdellben dot lansdell at gmail dot comIn this post I describe some of the theory of maximum likelihood estimation (MLE), highlighting its relation to information theory. In a later post I will develop the theory of maximum entropy models, also drawing connections to information theory, hoping to clarify the relation between MLE and MaxEnt.Installing NEURON with python and Neuronvisio2016-06-17T00:00:00+00:002016-06-17T00:00:00+00:00//benlansdell.github.io/computing/neurovisio<p>Since it took some time, I’m going to describe the steps I took to install NEURON with support for python and the 3D visualization tool neuronvisio. I’m running Ubuntu 14.04, python 2.7.</p>
<p>First, I installed the neuron python package found at http://neuralensemble.org/people/eilifmuller/software.html. Note that this installs NEURON 7.1, which is not the latest version.
I had to install also libreadline-dev to get nrnivmodl (the hoc compiler) working:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt-get install libreadline-dev
</code></pre></div></div>
<p>Then install the prerequisites for neuronvisio:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt-get install python-qt4 python-matplotlib python-setuptools python-tables mayavi2 python-pip
</code></pre></div></div>
<p>Install neuronvisio</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd ~/python/
git clone git://github.com/mattions/neuronvisio.git
python setup.py install
</code></pre></div></div>
<p>Add ~/python to your $PYTHONPATH, add ~/python/neuronvisio/bin/neuronvisio (or links thereto) to path
The final change (the most strange, and the that’s making me write this down) is as follows. Following steps 1-5 should get NEURON and neuronvisio working in python. I could run simulations, plot the 3D structures, etc. The one thing I was unable to do was to select segments in the 3D visualization window. I would receive the error:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Pick() takes exactly 4 arguments (2 given)
</code></pre></div></div>
<p>The workaround I found was to edit the following file in mayavi:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo vim /usr/lib/python2.7/dist-packages/mayavi/core/mouse_pick_dispatcher.py
</code></pre></div></div>
<p>So that the line changes from and to:
- 168: picker.pick((x, y, 0), self.scene.scene.renderer)
+ 168: picker.pick(x, y, 0, self.scene.scene.renderer)</p>
<p>It’s annoying that such a strange workaround was necessary. However, a similar fix was suggested here (https://github.com/enthought/mayavi/issues/21), so perhaps I wasn’t alone.</p>Ben Lansdellben dot lansdell at gmail dot comSince it took some time, I’m going to describe the steps I took to install NEURON with support for python and the 3D visualization tool neuronvisio. I’m running Ubuntu 14.04, python 2.7.Path integrals and SDEs in neuroscience2016-01-30T00:00:00+00:002016-01-30T00:00:00+00:00//benlansdell.github.io/statistics/sdes<p>An introduction to the relation between path integrals and stochastic differential equations, and how to use Feynman diagrams.</p>
<h2 id="introduction">Introduction</h2>
<p>The path integral was first considered by Wiener in the 1930s in his study of diffusion and Brownian motion. It was later co-opted by Dirac and by Richard Feynman in Lagrangian formulations of quantum mechanics. They provide a quite general and powerful approach to tackling problems not just in quantum field theory but in stochastic differential equations more generally. There is an associated learning curve to being able to make use of path integral methods, however, and for many problems simpler solution techniques exist.</p>
<p>Nonetheless, it is interesting to think about their application to neuroscience. In the following two posts I will describe how path integrals can be defined and used to solve simple SDEs, and why such ‘statistical mechanics’ tools may be useful in studying the brain. The following largely follows material from the paper “Path Integral Methods for Stochastic Differential Equations”, by Carson Chow and Michael Buice, 2012. This post will assume some familiarity with probability and stochastic processes.</p>
<h2 id="statistical-mechanics-in-the-brain">Statistical mechanics in the brain</h2>
<p>The cerebral cortex is the outer-most layer of the mammalian brain. In a human brain the *neocortex *consists of approximately 30 billion neurons. Of all parts of the human brain, its neural actvity is the most correlated with our *high-order *behaviour: language, self-control, learning, attention, memory, planning. Lesion and stroke studies make clear that the cortex has signficant functional localization, however, despite this localization, individual neurons from different regions of cortex in general require expert training to distinguish – these differences in functionality appear to arise largely from differences in connectivity.</p>
<p>The interplay between structural homogeniety and functional heterogeneity of different cortical regions poses definitive challenges to obtaining quantitative models of the large-scale activity of the cortex. Since structured neural activity is observed on spatial scales involving thousands to billions of neurons, and given that this activity is associated with particular functions and pathologies, dynamical models of large-scale cortical networks are definitely necessary to an understanding of these functions and dysfunctions. Examples of large-scale activities include wave-like activity during development, bump models of working memory, avalanches in awake and sleeping states, and pathological oscillations responsible for epileptic seizure.</p>
<p>A particular challenge to building such models is noise: it is well known that significant neural variability at both the individual and population level exists in response to repeated stimuli. The spike trains of individual cortical neurons are in general very noisy, such that their firing is often well approximated by a Poisson process. The primary source of cell intrinsic noise is fluctuations in ion channel activity, which arises from a finite number of ion channels opening and closing. While the primary source of extrinsic noise is from uncorrelated synaptic inputs – a neuron may contain thousands of synapses whose inputs often do not contain meaningful, correlated input. Population responses similarly exhibit highly variable responses. Models of cortical networks must account for this variability, or demonstrate that it is irrelevant to the particular questions being asked.</p>
<p>Methods from statistical mechanics lend themselves well to modelling both of these factors – statistical, but meaningful, connectivity, and noisy, but meaningful, neural responses to stimulus – in networks with large numbers of neurons. With these thoughts in mind, let’s see how path integrals may be used to study SDEs relevant to tackling the above issues.</p>
<h2 id="a-path-integral-representation-of-stochastic-differential-equations">A path integral representation of stochastic differential equations</h2>
<p>We will begin by describing in some detail how they are constructed and manipulated. In general, we would like to study SDEs that may be of the form:</p>
<div>
$$\frac{d\mathbf{x}}{dt}=\mathbf{f}(\mathbf{x})+\mathbf{g}(\mathbf{x})\mathbf{\eta}(t)$$
</div>
<p>for some noise process $\eta(t).$ Such a process may be characterized by either its probability density function (pdf, $p(x,t)$) or, equivalently, by its <em>moment heirarchy</em></p>
<div>
$$\langle x(t)\rangle,\quad\langle x(t)x(t')\rangle,\dots$$
</div>
<p>A generic SDE in the above form may be studied as either a Langevin equation, or can be written as a Fokker-Planck equation, but perturbation methods in either of these forms may be difficult to apply. The path integral approach is able to provide more mechanical methods for performing particular types of perturbation expansions. In the following sections we will derive a path integral formulation of a moment generating funcational of an SDE, using the Ornstein-Uhlenbeck process as an example. This will be used to demonstrate the use of perturbation techinques using Feynman diagrams. We will also derive the pdf $p(x,t)$ of such a process.</p>
<h2 id="path-integrals">Path integrals</h2>
<p>A path integral, loosely, is an integral in which the domain of
integration is not a subset of a finite dimensional space (say
$\mathbb{R}^{n}$) but instead an infinite dimensional function space.
For instance, if we can define the probability density associated with a
particular realization of a random trajectory according to a given SDE,
then the probability that a particle travels from a point $\mathbf{a}$
to a point $\mathbf{b}$ can be computed by marginalizing (summing) over
all paths connecting these two points, subject to a suitable
normalization. Before taking this further it is useful to review some relevant concepts.</p>
<h3 id="moment-generating-functions">Moment generating functions</h3>
<p>The moment generating function (MGF) forms a crucial component to this
framework. Recall that for a single random variable $X$, the <em>moments</em>
($\langle X\rangle=\int x^{n}P(x)\, dx$) are obtained from the MGF</p>
<div>
$$Z(\lambda)=\langle e^{\lambda x}\rangle=\int e^{\lambda x}P(x)\, dx$$
</div>
<p>by taking derivatives</p>
<div>
$$\langle X^{n}\rangle=\left.\frac{1}{Z(0)}\frac{d^{n}}{d\lambda^{n}}Z(\lambda)\right|_{\lambda=0},$$
</div>
<p>and that the MGF contains all information about RV $X$, as an alternative to studying the pdf directly.</p>
<p>In a similar fashion we can define \(W(\lambda)=\log Z(\lambda),\) so that</p>
<div>
$$\langle X^{n}\rangle_{C}=\frac{d^{n}}{d\lambda^{n}}\left.W(\lambda)\right|_{\lambda=0}$$
</div>
<p>are the <em>cumulants</em> of RV $X$.</p>
<p>For an $n$-dimensional random variable $\mathbf{x}=(x_{1},\dots,x_{n})$, the generating function is</p>
<div>
$$Z(\mathbf{\lambda})=\langle e^{\mathbf{\lambda}\cdot\mathbf{x}}\rangle=\int\prod_{i=1}^{n}dx_{i}e^{\mathbf{\lambda}\cdot\mathbf{x}}P(\mathbf{x})$$
</div>
<p>for $\lambda=(\lambda_{1},\dots,\lambda_{n})$. Here, the $k$-th order moments are obtained via</p>
<div>
$$\left\langle \prod_{i=1}^{k}x_{(i)}\right\rangle =\left.\frac{1}{Z(0)}\prod_{i=1}^{k}\frac{\partial^{n}}{\partial\lambda_{(i)}}Z(\lambda)\right|_{\lambda=0}.$$
</div>
<p>And, as before, the cumulant generating function is $W(\lambda)=\log Z(\lambda)$.</p>
<h3 id="stochastic-processes">Stochastic processes</h3>
<p>Instead of considering random variables in $n$ dimensions, we can
consider ‘infinite dimensional’ random variables through a time-slicing
limiting process. That is, we identify with each $x_{i}$ in $\mathbf{x}$
a time $t=ih$ such that $x_{i}=x(ih)$, and we let total time $T=nh$,
thereby splitting the interval $[0,T]$ into $n$ segments of length $h.$
From here, leaving any questions of convergence, etc, aside for the time
being, we can take the limit $n\to\infty$ (with $h=T/n$) such that
$x_{i}\to x(ih)=x(t)$, $\lambda_{i}\to\lambda(t)$ and
$P(\mathbf{x})\to P[x(t)]=\exp(-S[x(t)])$ for some functional $S[x]$
that we will call the <em>action</em>. Thus we envision that to compute the
MGF, instead of summing over all points in $\mathbb{R}^{n}$
$\left(\int\prod_{i=1}^{n}dx_{i}\right)$, we are instead summing over
all paths using a differential denoted $\int\mathcal{D}x(t)$:</p>
<div>
$$Z[\lambda]=\int\mathcal{D}x(t)\, e^{-S[x]+\int\lambda(t)x(t)\, dt}.$$
</div>
<p>From this formula, moments can now be obtained via</p>
<div>
$$\left\langle \prod_{i=1}^{k}x(t_{(i)})\right\rangle =\frac{1}{Z[0]}\left.\prod_{i=1}^{k}\frac{\delta}{\delta\lambda(t_{(i)})}Z[\lambda]\right|_{\lambda(t)=0},$$
</div>
<p>with the cumulant generating functional again being</p>
<div>
$$W[\lambda]=\log(Z[\lambda]).$$
</div>
<h3 id="generic-gaussian-processes">Generic Gaussian processes</h3>
<p>The most important random process we consider is the Gaussian. Recall
that in one dimension the RV $X\sim N(a,\sigma^{2})$ has MGF</p>
<div>
$$Z(\lambda)=\int_{-\infty}^{\infty}\exp\left[\frac{-(x-a)^{2}}{2\sigma^{2}}+\lambda x\right]\, dx=\sqrt{2\pi}\sigma\exp(\lambda a+\lambda^{2}\sigma^{2}/2),$$
</div>
<p>which is obtained by a ‘completing the square’ manipulation, and has cumulant GF</p>
<div>
$$W(\lambda)=\lambda a+\frac{1}{2}\lambda^{2}\sigma^{2}+\log(Z(0)),$$
</div>
<p>so that the cumulants are
$\langle x\rangle_{C}=a,\langle x^{2}\rangle_{C}=\text{var}{X}=\sigma^{2}$ and
$\langle x^{k}\rangle_{C}=0$ for all $k>2$.</p>
<p>The $n$ dimensional Gaussian RV $X\sim N(0,K)$, with covariance matrix $K$, has MGF</p>
<div>
$$Z(\lambda)=\int_{-\infty}^{\infty}e^{-\frac{1}{2}\sum_{jk}x_{j}K_{jk}^{-1}x_{k}+\sum_{j}\lambda_{j}x_{j}}\, dx$$
</div>
<p>This integral can also be integrated exactly. Indeed, since $K$ is
symmetric positive definite (and so is $K^{-1}$), we can diagonalise in
orthonormal coordinates, making each dimension independent, and allowing
the integration to be performed one dimension at a time. This provides
\(Z(\lambda)=[2\pi\det(K)]^{n/2}e^{\frac{1}{2}\sum_{jk}\lambda_{j}K_{jk}\lambda_{k}}.\)
In an analogous fashion, through the same limiting process described
above, the infinite dimensional case is</p>
<div>
$$Z[\lambda]=\int\mathcal{D}x(t)e^{-\frac{1}{2}\int x(s)K^{-1}(s,t)x(t)dsdt+\int\lambda(t)x(t)dt}=Z[0]e^{\frac{1}{2}\int\lambda(s)K(s,t)\lambda(t)dsdt}.$$
</div>
<p>Importantly for perturbation techniques, higher order (centered) moments
of multivariate Gaussian random variables can be expressed simply as a
sum of products of their second moments. This result is known as Wick’s
theorem:</p>
<div>
$$
\left\langle \prod_{i=1}^{k} x_{(i)} \right\rangle = \begin{cases} 0, & k\text{ odd}\\
\sum_{\sigma\in A}K_{\sigma(1)\sigma(2)}K_{\sigma(3)\sigma(4)}\cdots K_{\sigma(k-1)\sigma(k)}, & k\text{ even}\end{cases}
$$
</div>
<p>for $A={\text{all pairings of }x_{(i)}}$. Only even
moments are non-zero. Note that this means that the covariance matrix
$K$ is the key to determining all higher order moments. Wick’s theorem lies at the heart of calculations utilizing Feynman diagrams.</p>
<h2 id="applications-to-sdes">Applications to SDEs</h2>
<p>The previous construction for generic Gaussian processes can be adapted to construct a moment generating functional for generic SDEs of the form</p>
<div>
$$\frac{dx}{dt}=f(x,t)+g(x)\eta(t)+y\delta(t-t_{0}),$$
</div>
<p>for $t\in[0,T]$. The process involves the same time-slicing approach, in which the above SDE is discretized in time steps $h$</p>
<div>
$$x_{i+1}-x_{i}=f_{i}(x_{i})h+g_{i}(x_{i})w_{i}\sqrt{h}+y\delta_{i,0}$$
</div>
<p>under the Ito interpretation. We assume that each $w_{i}$ is a Guassian with $\langle w_{i}\rangle=0$ and
$\langle w_{i}w_{j}\rangle=\delta_{ij}$ such that $w_{i}$ describes a
Guassian white noise process. Then the PDF of $\mathbf{x}$ given a
particuar instantiation of a random walk ${w_{i}}$ is</p>
<div>
$$P[x|w;y]=\prod_{i=0}^{n}\delta[x_{i+1}-x_{i}+f_{i}(x_{i})h-g_{i}(x_{i})w_{i}\sqrt{h}-y\delta_{i,0}].$$
</div>
<p>If we take the Fourier transform of the PDF:</p>
<div>
$$P[x|w;y]=\int\prod_{j=0}^{N}\frac{dk_{j}}{2\pi}e^{-i\sum_{j}k_{j}(x_{j+1}-x_{j}-f_{j}(x_{j})h-g_{j}(x_{j})w_{j}\sqrt{h}-y\delta_{j,0})}$$
</div>
<p>where we’ve made use of the fact that the Dirac delta function has
Fourier transform:</p>
<div>
$$\mathcal{F}\{\delta(x-x_{0});x\to k\}=\frac{1}{2\pi}e^{-ix_{0}k}.$$
</div>
<p>Marginalizing over all random trajectories ${w}$ and evaluating the
resulting Gaussian integral gives:</p>
<div>
$$P[x|y]=\int\prod_{j=0}^{N}\frac{dk_{j}}{2\pi}e^{-\sum_{j}(ik_{j})\left(\frac{x_{j+1}-x_{j}}{h}-f_{j}(x_{j})-y\delta_{j,0}/h\right)h+\sum_{j}\frac{1}{2}g_{j}^{2}(x_{j})(ik_{j})^{2}h}$$
</div>
<p>Again we take the continuum limit by letting $h\to0$ with $N=T/h$, and
by replacing $ik_{j}$ with $\tilde{x}(t)$ and
${\displaystyle \frac{x_{j+1}-x_{j}}{h}}$ with $\dot{x}(t)$:</p>
<div>
$$P[x(t)|y,t_{0}]=\int\mathcal{D}\tilde{x}(t)e^{-\int[\tilde{x}(t)(\dot{x}(t)-f(x(t),t)-y\delta(t-t_{0}))-\frac{1}{2}\tilde{x}^{2}g^{2}(x(t),t)]dt}.$$
</div>
<p>The function $\tilde{x}(t)$ represents a function of the wave numbers
$k_{j}$, thus we can write down a moment generating functional for both
its position and its conjugate space:</p>
<div>
$$Z[J,\tilde{J}]=\int\mathcal{D}x(t)\mathcal{D}\dot{x}(t)e^{-S[x,\tilde{x}]+\int\tilde{J}x\, dt+\int J\tilde{x}\, dt}$$
</div>
<p>More generally, instead of $g(x)\eta(t)$ with $\eta(t)$ a white noise
process, an SDE having a noise process with cumulant $W[\lambda(t)]$
will have the PDF:</p>
<div>
$$\begin{aligned}
P[x(t)|y,t_{0}] & = \int\mathcal{D}\eta(t)\delta[\dot{x}(t)-f(x,t)-\eta(t)-y\delta(t-t_{0})]e^{-S[\eta(t)]}\\
& = \int\mathcal{D}\eta(t)\mathcal{D}\tilde{x}(t)e^{-\int\tilde{x}(t)(\dot{x}(t)-f(x,t)-y\delta(t-t_{o}))\, dt+W[\tilde{x}(t)]}\end{aligned}$$
</div>
<p>If $\eta(t)$ is delta correlated
($\langle\eta(t)\eta(t’)\rangle=\delta(t-t’)$) then $W[\tilde{x}(t)]$
can be Taylor expanded in both $x(t)$ and $\tilde{x}(t)$:</p>
<div>
$$W[\tilde{x}(t)]=\sum_{n=1,m=0}^{\infty}\frac{v_{nm}}{n!}\int\tilde{x}^{n}(t)x^{m}(t)\, dt.$$
</div>
<p>Note that the summation over $n$ starts at one because
$W[0]=\log(Z[0])=0$.</p>
<h2 id="the-ornstein-uhlenbeck-process">The Ornstein-Uhlenbeck process</h2>
<p>As an example, consider the Orstein-Uhlenbeck process</p>
<div>
$$\dot{x}(t)+ax(t)-\sqrt{D}\eta(t)=0$$
</div>
<p>which has the action</p>
<div>
$$S[x,\tilde{x}]=\int\left[\tilde{x}(t)(\dot{x}(t)+ax(t)-y\delta(t-t_{0}))-\frac{D}{2}\tilde{x}^{2}(t)\right]\, dt.$$
</div>
<p>The moments could found immedately, since action is quadratic in
$\tilde{x}(t)$[^1], however we instead demonstrate how to study the
problem through a perturbation expansion. In this case the perturbation
will truncate to the exact, and already known, solution. The idea is to
break the action into a ‘free’ and ‘interacting’ component. The
terminology comes from quantum field theory in which free terms
typically represent a particle without any interaction with a field or
potential, and would have a quadratic action. The free action can
therefore be evaluated exactly, and the interaction term can be
expressed as an ‘asymptotic series’ around this solution. Let the action
be written</p>
<div>
$$\begin{aligned}
S & = S_{F}+S_{I}\\
& = \int\tilde{x}(t)\left[\dot{x}(t)+ax(t)\right]\, dt+\int\tilde{x}(t)y\delta(t-t_{0})-\frac{D}{2}\tilde{x}^{2}(t)\, dt\end{aligned}$$
</div>
<p>We define the function $G$, known as the the linear response function or
correlator or propagator, to be the Green’s function of the linear
differential operator corresponding to the free action:</p>
<div>
$$\left(\frac{d}{dt}+a\right)G(t,t')=\delta(t-t')$$
</div>
<p>Note that $G(t,t’)$
is in fact exactly equivalent to $K(t,t’)$ from the generic Gaussian
stochastic process derived previously. Note also that, in general, the
‘inverse’ of a Green’s function$G(t,t’)$ is an integral operator
satisfying:</p>
<div>
$$\mathcal{L}G=\int dt''G^{-1}(t,t'')G(t'',t')=\delta(t-t')=\left(\frac{d}{dt}+a\right)G(t,t'),$$
</div>
<p>for some $G^{-1}(t,t’)$. The operator $\mathcal{L}$ would indeed be such
an inverse for the following choice of $G^{-1}$:</p>
<div>
$$G^{-1}(t,t')=\left(\frac{d}{dt}+a\right)\delta(t-t').$$
</div>
<p>The free
generating functional, then, is</p>
<div>
$$Z_{F}[J,\tilde{J}]=\int\mathcal{D}x(t)\mathcal{D}\tilde{x}(t)e^{-\int dtdt'\tilde{x}(t)G^{-1}(t,t')x(t)+\int\tilde{x}(t)J(t)\, dt+\int x(t)\tilde{J}(t)\, dt}.$$
</div>
<p>So, analogous to the multivariate Gaussian case, we can evaluate this
integral exactly to obtain:</p>
<div>
$$Z_{F}[J,\tilde{J}]=e^{\int\tilde{J}G(t,t')J\, dtdt'}.$$
</div>
<p>For the OU process we can in fact solve the linear differential equation
for Green’s function $G$: \(G(t,t')=H(t-t')e^{-a(t-t')}.\) The <em>free</em>
<em>moments</em> are then given by</p>
<div>
$$\left\langle \prod_{ij}x(t_{i})\tilde{x}(t_{j})\right\rangle _{F}=\left.\prod_{ij}\frac{\delta}{\delta\tilde{J}(t_{i})}\frac{\delta}{\delta J(t_{j})}e^{\int\tilde{J}(t)G(t,t')J(t')\, dtdt'}\right|_{J=\tilde{J}=0}.$$
</div>
<p>Importantly, note that</p>
<div>
$$\left\langle x(t_{1})\tilde{x}(t_{2})\right\rangle _{F}=\left.\frac{\delta}{\delta\tilde{J}(t_{1})}\frac{\delta}{\delta J(t_{2})}e^{\int\tilde{J}(t)G(t,t')J(t')\, dtdt'}\right|_{J=\tilde{J}=0}=G(t_{1},t_{2})$$
</div>
<p>and
$\langle\tilde{x}(t_{1})\tilde{x}(t_{2})\rangle_{F}=\langle x(t_{1})x(t_{2})\rangle_{F}=0$.</p>
<p>Since the only non-zero second order moments are those in which an
$x(t)$ is paired with an $\tilde{x}(t’)$ then Wick’s theorem means that
all non-zero higher order <em>free moments</em> must have equal numbers of
$x$’s as $\tilde{x}$’s. This is important in performing the expansions
below.</p>
<h3 id="using-feynman-diagrams">Using Feynman diagrams</h3>
<p>We have split the action into, loosely, linear and non-linear parts[^2]
$S=S_{F}+S_{I}$ so that the MGF can be written:</p>
<div>
$$\begin{aligned}
Z[J,\tilde{J}] & = \int\mathcal{D}x(t)\mathcal{D}\tilde{x}(t)e^{-S_{F}-S_{I}+\int\tilde{J}x+\int J\tilde{x}}\\
& = \int\mathcal{D}x(t)\mathcal{D}\tilde{x}(t)P_{F}[x(t),\tilde{x(t)}]e^{-S_{I}+\int\tilde{J}x+\int J\tilde{x}}\\
& = \int\mathcal{D}x(t)\mathcal{D}\tilde{x}(t)P_{F}[x(t),\tilde{x(t)}]\sum_{n=0}^{\infty}\frac{1}{n!}(-S_{I}+\int\tilde{J}x+\int J\tilde{x})^{n}\\
& = \sum_{n=0}^{\infty}\frac{1}{n!}\left\langle \mu^{n}\right\rangle _{F}\end{aligned}$$
</div>
<p>with $\mu=S_{I}+\int\tilde{J}x\, dt+\int J\tilde{x}\, dt$.</p>
<p>We have now expressed the MGF in terms of a sum of free moments, which
we know how to evaluate. To proceed, expand $S_{I}$:</p>
<div>
$$S_{I}=\sum_{m\ge0,n\ge0}V_{mn}=\sum_{m\ge0,m\ge n}v_{mn}\int x^{m}\tilde{x}^{n}\, dt.$$
</div>
<p>In evaluating the expression for $Z$, there exists a diagrammatic way to
visualize each term that we need to consider for a desired moment.
Recall that the only free moments that are going to be non-zero are the
ones containing equal numbers of $x(t)$ and $\tilde{x(t)}$ terms. Wick’s
theorem then expresses these moments as the sum of the product of all
possible pairings between the $x(t)$ and $\tilde{x}(t)$ terms. Thus each
term of the multinomial expansion</p>
<div>
$$\left\langle \left(\sum_{n\ge0,m\ge0}v_{mn}\int x^{m}\tilde{x}^{n}\, dt+\int\tilde{J}xdt+\int J\tilde{x}dt\right)^{n}\right\rangle _{F}$$
</div>
<p>can be thought of in terms of these pairings. The idea is that with each
$V_{mn}$ in $S_{I}$ we associate an <em>internal vertex</em> having $m$
entering edges and $n$ exiting edges. The $\int{J}\tilde{x}$ and
$\int\tilde{J}{x}$ terms contribute, respectively, entering and exiting
<em>external vertices.</em> Edges connecting vertices then correspond to a
pairing between an $x(t)$ and $\tilde{x}(t)$. Finally, since</p>
<div>
$$\left\langle \prod_{i=1}^{N}\prod_{j=1}^{M}x(t_{i})\tilde{x}(t_{j})\right\rangle =\frac{1}{Z[0,0]}\left.\frac{\delta}{\delta J(t_{i})}\frac{\delta}{\delta\tilde{J}(t_{j})}Z\right|_{J=\tilde{J}=0}$$
</div>
<p>then only the terms in the expansion for $Z$ having $N$ entering and $M$
exiting external vertices (and thus $N$ and $M$ auxillary terms) will
contribute to that moment. These terms are represented by *Feynman
diagrams, *which is a graph composed of a combination of these vertices
and in which each of the $N$ external vertices is connected (paired
with) $M$ external vertices, possibly through a number of the internal
vertices. Moments can be simply computed by writing down all possible
diagrams with the requiste number of external vertices.</p>
<p>As an example, the coupling between external vertex
$\int\tilde{J}x\, dt$ and internal vertex
$\int\delta(t-t_{0})y\tilde{x}(t)\, dt$ in $Z$ can be evaluated as:</p>
<div>
$$\begin{aligned}
Z & = \left\langle \int dtdt'\,\tilde{J}(t)x(t)y\delta(t'-t_{0})\tilde{x}(t')\right\rangle _{F}+\text{all other terms}\\
& = \int dtdt'\,\tilde{J}(t)y\delta(t'-t_{0})\left\langle x(t)\tilde{x}(t')\right\rangle _{F}+\text{all other terms}\\
& = \int dt\, y\tilde{J}(t)G(t,t_{0})+\text{all other terms}.\end{aligned}$$
</div>
<p>But this is best explained diagrammatically. In our case we have:</p>
<div>
$$S_{I}=\int dt\, y\delta(t-t_{0})\tilde{x}(t)+\int dt\,\frac{D}{2}\tilde{x}^{2}(t),$$
</div>
<p>and the relevant vertices are illustrated in Figure 1. The process for
then computing the first and second moment for the OU process is
illustrated in Figure 2. We can see that each term will be written as an
integral involving the auxillary functions $J$, $\tilde{J}$ and the
propagator $G$. In general, each vertex in each diagram is assigned
temporal index $t_{k}$.</p>
<figure class="center" style="width:300px">
<img src="../../images/feynman1.png" alt="img txt" />
<figcaption>Figure 1. Vertices involved in evaluating moments of example OU process. First
two vertices are internal vertices and are a part of the interacting
action $S_{I}$, the next two vertices are external vertices associated
with an auxillary variable $J$, $\tilde{J.}$ Each edge of a Feynman
diagram contributes a propagator $G(t,t')$.
</figcaption>
</figure>
<figure class="center" style="width:500px">
<img src="../../images/feynman2.png" alt="img txt" />
<figcaption>Figure 2. Computation of first and second cumulant using Feynman diagrams. Mean
is given by functional derivative with respect to one auxillary function
$\tilde{J}$, evaluated at zero. The only term non-zero term is
represented by a diagram containing one exiting vertex, and no entering
vertex. In this case the only diagram possible is composed of the
internal vertex representing the initial condition paired with the
exiting vertex. Evaluating the free moment and taking the functional
derivative of this term gives the mean in terms of $G(t,t')$. In a
similar fashion, the second cumulant is also calculated.
</figcaption>
</figure>
<p>In OU, in fact only a finite number of diagrams can be considered and
the exact mean and covariance can be determined. This is a result of the
linearity of the SDE: a linear SDE can be written to have no $x$ terms
in $S_{I}$, which means all internal vertices have no entering edges and
that all moments in $x$ must correspond to a finite number of diagrams
(in contrast to internal vertices with both entering and exiting edges
which can then be combined in an infinite number of ways). In this case,
from Figure 2, the mean and covariance are given by:</p>
<div>
$$\langle x(t)\rangle=yH(t-t_{0})e^{-a(t-t_{0})}$$
</div>
<p>and</p>
<div>
$$\langle x(t)x(s)\rangle_{C}=D\frac{e^{2a(t-s)}-e^{2a(t+s-2t_{0})}}{2a}.$$
</div>
<p>In summary
———-</p>
<p>We’ve seen how to construct a path integral formulation of a generic SDE. And have seen how to construct Feynman diagrams perform perturbation expansions for the solution. In a <a href="http://benlansdell.github.io/statistics/sdesII/">follow-up post</a> we will consider more examples of how they can be used.</p>Ben Lansdellben dot lansdell at gmail dot comAn introduction to the relation between path integrals and stochastic differential equations, and how to use Feynman diagrams.Path integrals and SDEs in neuroscience – part two2016-01-30T00:00:00+00:002016-01-30T00:00:00+00:00//benlansdell.github.io/statistics/sdesII<p>In the <a href="http://benlansdell.github.io/statistics/sdes/">previous post</a> we defined path integrals through a simple ‘time-slicing’ approach. And used them to compute moments of simple stochastic DEs. In this follow-up post we will examine how expansions can be used to approximate moments, how we can use the moment generating functional to compute probability densities, and how these methods may be helpful in some cases in neuroscience.</p>
<h3 id="perturbation">Perturbative approaches</h3>
<p>For a general, non-linear, SDE the series will not terminate and must be
truncated at some point. It is then necessary to determine which terms
will contribute the sum, and to include these terms up to a given order.
We mention briefly three such possibilities, though do not discuss them
in any detail. One way of doing this is if some terms in $S_{I}$
($v_{mn}\int x^{n}\tilde{x}^{m},m\ge2$) are small. Then we can simply
let each such vertex contribute a small parameter $\alpha$ and perform
an expansion in orders of $\alpha$ (known as a ‘weak coupling expansion’
<sup id="fnref:3" role="doc-noteref"><a href="#fn:3" class="footnote" rel="footnote">1</a></sup>).</p>
<p>Another option is to perform a weak noise, or loop, expansion. Here we
scale the entire exponent in the MGF by some factor $h$</p>
<div>
$$Z=\int\mathcal{D}x(t)\mathcal{D}\tilde{x}(t)e^{-\frac{1}{h}(S-\int\tilde{J}x-\int J\tilde{x})}$$
</div>
<p>Then each vertex of $S_{I}$ gains a factor of $1/h$ and each edge of
$S_{F}$ gains a factor $h$ which implies we can expand in powers of $h$.
In performing this expansion, if we let $E$ denote the number of
external edges of a diagram, $I$ the number of internal edges and $V$
the number of vertices then each connected graph has a factor of
\(h^{I+E-V}\) and, in fact, it can be shown by induction that:
\(L=I-V+1\) where $L$ is the number of *loops *the diagram contains.
Thus, each graph collects a factor of $h^{E-L+1}$. This allows us to
order the expansion in terms of the number of loops in each diagram.
Diagrams which contain no loops are trees, or classical diagrams. Such
diagrams form the basis of the *semi-classical *approximation.</p>
<p>This expansion is of course only valid when the contribution of the
higher loop number diagrams is smaller than that of the lower loop
number diagrams. The <em>Ginzburg</em> *criterion *says when this expansion is
indeed valid.</p>
<h2 id="some-other-examples">Some other examples</h2>
<p>We present two further examples which demonstrate how these methods are
used.</p>
<h3 id="example-1">Example 1</h3>
<p>A simple extension of the OU process so that it is now <em>mean-reverting</em>
(to something not zero, as in the previous case) is the SDE</p>
<div>
$$\dot{x}(t)+a(b+x(t))-\sqrt{D}\eta(t)=0.$$
</div>
<p>This problem is obviously very similar to the above problem and is of
course solved almost identically. This time the action of the process is</p>
<div>
$$S=\int\left[\tilde{x}(t)(\dot{x}(t)+a(b+x(t)))+\tilde{x}(t)y\delta(t-t_{0})-\frac{D}{2}\tilde{x}^{2}(t)\right]\, dt$$
</div>
<p>such that the free action is as before:</p>
<div>
$$S_{F}=\int\tilde{x}(t)\left[\dot{x}(t)+ax(t))\right]\, dt$$
</div>
<p>(the
linear, homogenous part, for which a Green’s function can be calculated)
and the interacting action is:</p>
<div>
$$S_{I}=\int\left[\tilde{x}(t)\left(y\delta(t-t_{0})+ba\right)-\frac{D}{2}\tilde{x}^{2}(t)\right]\, dt.$$
</div>
<p>The only details that change are thus that the vertex linear in
$\tilde{x}(t)$ changes from</p>
<div>
$$\int\tilde{x}(t)y\delta(t-t_{0})dt\to\int\tilde{x}(t)\left(y\delta(t-t_{0})+ba\right)dt,$$
</div>
<p>which adds an extra term to the expression for the mean:</p>
<div>
$$\langle x(t)\rangle=H(t-t_{0})\left(ye^{-a(t-t_{0})}+b(1-ye^{-a(t-t_{0})})\right).$$
</div>
<p>Since only this internal vertex is affected, and the second order vertex
($D\tilde{x}(t)^{2}/2$) is unaffected, the solution for the second-order
cumulant will in fact be the same as our original example:</p>
<div>
$$\langle x(t)x(s)\rangle_{C}=D\frac{e^{2a(t-s)}-e^{2a(t+s-2t_{0})}}{2a}$$
</div>
<h3 id="example-2">Example 2</h3>
<p>Consider the harmonic oscillator with noise:</p>
<div>
$$\ddot{x}+2\gamma\dot{x}+\omega^{2}x=\sqrt{D}\eta(t)$$
</div>
<p>where $\eta$ is
a white noise process. Subject to initial conditions $x(0)=x_{0}$ and
$\dot{x}(0)=v_{0}$ ($t_{0}=0$). The action for this process is</p>
<div>
$$S=\int dt\,\left(\tilde{x}\left[\ddot{x}+2\gamma\dot{x}+\omega^{2}x+v_{0}\delta(t)+x_{0}\delta'(t)\right]+\frac{D}{2}\tilde{x}^{2}\right)$$
</div>
<p>which we will split into free and interacting components:</p>
<div>
$$\begin{aligned}
S_{F} & = \int dt\,\left(\tilde{x}\left[\ddot{x}+2\gamma\dot{x}+\omega^{2}x\right]\right)\\
S_{I} & = \int dt\,\left(\tilde{x}\left[v_{0}\delta(t)+x_{0}\delta'(t)\right]+\frac{D}{2}\tilde{x}^{2}\right)\end{aligned}$$
</div>
<p>The free action gives the propagator as the Green’s function:</p>
<div>
$$\left(\frac{d^{2}}{dt^{2}}+2\gamma\frac{d}{dt}+\omega^{2}\right)G(t,t')=\delta(t-t')$$
</div>
<p>which can be shown to be</p>
<div>
$$G(t,t')=\frac{1}{\omega_{1}}H(t-t')e^{-\gamma(t-t')}\sin[\omega_{1}(t-t')],$$
</div>
<p>for $\omega_{1}=\sqrt{\omega^{2}-\gamma^{2}}$. Once $G$ is determined
the mean and covariance can be immediately calculated through the
diagrams and calculations of the Figure 1.</p>
<figure class="center" style="width:500px">
<img src="../../images/feynman3.png" alt="img txt" />
<figcaption>Figure 1. Computation of first and second cumulant of Brownian motion process
with Gaussian white noise. Diagrams (with internal vertices labeled
adjacent to diagram), and the equivalent integral to evaluate to obtain
each cumulant.
</figcaption>
</figure>
<p>We find, as expected, the following mean and covariance:</p>
<div>
$$\begin{aligned}
\langle x(t)\rangle & = \int[\delta(t')v_{0}+\delta'(t')x_{0}]G(t,t')dt'\\
& = v_{0}G(t,0)+x_{0}G'(t,0)\\
& = e^{-\gamma t}\left(\frac{\gamma x_{0}+v_{0}}{\omega_{1}}\sin[\omega_{1}t]+\cos[\omega_{1}t]\right)\end{aligned}$$
</div>
<p>and (assuming $t_{1}<t_{2}$)</p>
<div>
$$\begin{aligned}
\langle x(t_{1})x(t_{2})\rangle_{C} & = D\int G(t_{1},t)G(t_{2},t)dt\\
& = \frac{D}{\omega_{1}^{2}}\int_{0}^{\infty}e^{-\gamma(t_{1}+t_{2}-2t)}H(t_{1}-t)H(t_{2}-t)\sin[\omega_{1}(t_{1}-t)]\sin[\omega_{1}(t_{2}-t)]dt\\
& = \frac{D{\rm e}^{-\gamma\,{\it t_{1}}-\gamma\,{\it t_{2}}}}{4\omega_{1}^{2}\omega^{2}\gamma}\left({\rm e}^{2\,\gamma\,{\it t1}}\left[\cos\left(\omega_{1}\,{\it t_{1}}\right)\cos\left(\omega\,{\it t_{2}}\right)\omega_{1}^{2}+\cos\left(\omega_{1}\,{\it t_{1}}\right)\sin\left(\omega_{1}\,{\it t_{2}}\right)\gamma\,\omega_{1}-\cos\left(\omega_{1}\,{\it t_{2}}\right)\sin\left(\omega_{1}\,{\it t_{1}}\right)\gamma\,\omega_{1}\right]\right.\\
& + {\rm e}^{2\,\gamma\,{\it t_{1}}}\sin\left(\omega_{1}\,{\it t_{1}}\right)\sin\left(\omega_{1}\,{\it t_{2}}\right)\omega_{1}^{2}-\cos\left(\omega_{1}\,{\it t_{1}}\right)\cos\left(\omega_{1}\,{\it t_{2}}\right)\omega_{1}^{2}-\omega_{1}\,\cos\left(\omega_{1}\,{\it t_{1}}\right)\sin\left(\omega_{1}\,{\it t_{2}}\right)\gamma\\
& + \left.\omega_{1}\,\sin\left(\omega_{1}\,{\it t_{1}}\right)\cos\left(\omega_{1}\,{\it t_{2}}\right)\gamma-2\,\gamma^{2}\sin\left(\omega_{1}\,{\it t_{1}}\right)\sin\left(\omega_{1}\,{\it t_{2}}\right)-\sin\left(\omega_{1}\,{\it t_{1}}\right)\sin\left(\omega_{1}\,{\it t_{2}}\right)\omega^{2}\right)\end{aligned}$$
</div>
<p>which, with some rearrangement, simplifies to the variance<sup id="fnref:4" role="doc-noteref"><a href="#fn:4" class="footnote" rel="footnote">2</a></sup>:</p>
<div>
$$\langle x(t)^{2}\rangle_{C}=\frac{D}{4\gamma\omega^{2}}\left[1-\exp(-2\gamma t)\left\{ 1+\frac{\gamma}{\omega_{1}}\left(\sin(2\omega_{1}t)+\frac{2\gamma}{\omega_{1}}\sin^{2}(\omega_{1}t)\right)\right\} \right].$$
</div>
<p>Connection to Fokker-Planck Equation
————————————</p>
<p>So far we have considered the moment generating functional, and the
probability density functional $P[x(t)]$, however often of interest is
the probability density $p(x,t)$. This can be computed from the above
framework with the following derivation.</p>
<p>Let $U(x_{1},t_{1}|x_{0},t_{0})$ be the transition probability between a
start point $x_{0},t_{0}$ to $x_{1},t_{1}$, then</p>
<div>
$$\begin{aligned}
U(x_{1},t_{1}|x_{0},t_{0}) & = \int\mathcal{D}x(t)\delta(x(t_{1})-x_{1})P[x(t)]\\
& = \frac{1}{2\pi i}\int d\lambda\int\mathcal{D}x(t)e^{-\lambda(x(t_{1})-x_{1})}P[x(t)]\\
& = \frac{1}{2\pi i}\int d\lambda e^{-\lambda(x_{1}-x_{0})}Z_{CM}(\lambda)\end{aligned}$$
</div>
<p>where $Z_{CM}$ gives the moments of $x(t_{1})-x_{0}$ given
$x(t_{0})=x_{0}$</p>
<div>
$$Z_{CM}=\int\mathcal{D}xe^{\lambda(x(t_{1})-x_{0})}P[x(t)]$$
</div>
<p>Using the
following two relations:</p>
<div>
$$\begin{aligned}
Z_{CM}(\lambda) & = 1+\sum_{n=1}^{\infty}\frac{1}{n!}\langle(x(t_{1})-x_{0})^{n}\rangle_{x(t_{0})=x_{0}}\\
\frac{1}{2\pi i}\int d\lambda\, e^{-\lambda(x_{1}-x_{0})}\lambda^{n} & = \left(-\frac{\partial}{\partial x_{1}}\right)^{n}\delta(x_{1}-x_{0})\end{aligned}$$
</div>
<p>then $U$ becomes</p>
<div>
$$U(x_{1},t_{1}|x_{0},t_{0})=\left(1+\sum_{n=1}^{\infty}\frac{1}{n!}\left(-\frac{\partial}{\partial x_{1}}\right)^{n}\langle(x(t_{1})-x_{0})^{n}\rangle_{x(t_{0})=x_{0}}\right)\delta(x_{1}-x_{0}).$$
</div>
<p>From here we can derive a relation for $p(x,t)$:</p>
<div>
$$\begin{aligned}
p(y,t+\Delta t) & = \int U(x,t+\Delta t|y',t)p(y',t)\, dy'\\
& = \int\left(1+\sum_{n=1}^{\infty}\frac{1}{n!}\left(-\frac{\partial}{\partial y}\right)^{n}\langle(x(t_{1})-y')^{n}\rangle_{x(t)=y'}\right)\delta(y-y')p(y',t)\, dy'\\
& = \left(1+\sum_{n=1}^{\infty}\frac{1}{n!}\left(-\frac{\partial}{\partial y}\right)^{n}\langle(x(t_{1})-y)^{n}\rangle_{x(t)=y}\right)p(y,t)\end{aligned}$$
</div>
<p>and thus a PDE for $p(x,t)$:</p>
<div>
$$\begin{aligned}
\frac{\partial p(y,t)}{\partial t}\Delta t & = \sum_{n=1}^{\infty}\frac{1}{n!}\left(-\frac{\partial}{\partial y}\right)^{n}\langle(x(t_{1})-y)^{n}\rangle_{x(t)=y}p(y,t)+O(\Delta t^{2})\\
\frac{\partial p(y,t)}{\partial t} & = \sum_{n=1}^{\infty}\frac{1}{n!}\left(-\frac{\partial}{\partial y}\right)^{n}D_{n}(y,t)p(y,t)\end{aligned}$$
</div>
<p>as $\Delta t\to0$. This is the Kramers-Moyal expansion where
the $D_{n}$are</p>
<div>
$$D_{n}(y,t)=\lim_{\Delta t\to0}\left.\frac{\langle(x(t+\Delta t)-y)^{n}\rangle}{\Delta t}\right|_{x(t)=y}$$
and are computed from the SDE. For example, for the Ito process
</div>
<p>\(dx=f(x,t)dt+g(x,t)dB_{t}\) we can compute $D_{1}(y,t)=f(y,t)$ and
$D_{2}(y,t)=g(y,t)^{2}$, $D_{n}=0$ for $n>2$. Hence the PDE becomes a
Fokker-Planck equation</p>
<div>
$$\frac{\partial p(y,t)}{\partial t}=\left(\frac{\partial}{\partial y}D_{1}(y,t)+\frac{1}{2}\frac{\partial^{2}}{\partial y^{2}}D_{2}(y,t)\right)p(y,t)$$
</div>
<p>Compute $p(x,t)=U(x,t|0,0)$ as</p>
<div>
$$\begin{aligned}
p(x,t) & = \frac{1}{2\pi i}\int d\lambda\, e^{-\lambda x}Z_{CM}(\lambda)\\
& = \frac{1}{2\pi i}\int d\lambda\, e^{-\lambda x}\exp\left[\sum_{n=1}\frac{1}{n!}\lambda^{n}\langle x(t)^{n}\rangle_{C}\right]\end{aligned}$$
</div>
<p>For OU, we know the cumulants hence</p>
<div>
$$p(x,t)=\sqrt{\frac{a}{\pi D(1-e^{-2a(t-t_{0})})}}\exp\left(\frac{-a(x-ye^{-a(t-t_{0})})^{2}}{D(1-e^{-2a(t-t_{0})})}\right)$$
</div>
<p>Statistical mechanics of the neocortex
======================================</p>
<p>Having spent some time on how path integrals can be used as
calculation devices for studying stochastic DEs, we now turn to some
specific examples of their use in neuroscience.</p>
<h2 id="neural-field-models">Neural field models</h2>
<p>A neural field model represents a continuum approximation to neural
activity (particularly in models of cortex). They are often expressed as
integro-differential equations:</p>
<div>
$$dU=\left[-U+\int_{-\infty}^{\infty}w(x-y)F(U(y,t))dy\right]dt$$
</div>
<p>where
$U=U(x,t)$ may be either the mean firing rate or a measure of synaptic
input at position $x$ and time $t$. The function $w(x,y)=w(|x-y|)$ is a
weighting function often taken to represent the synaptic weight as a
function of distance from $x$. $F(U)$ is a measure of the firing rate as
a function of inputs. For tractability, $F$ may often be taken to be a
heaviside function, or a sigmoid curve. It is called a field because
each continuous point $x$ is assigned a value $U$, instead of modelling
the activity of individual neurons. A number of spatio-temporal pattern
forming systems may be studied in the context of these models. The
formation of ocular-dominance columns, geometric hallucinations,
persistent ‘bump models’ of activity associated with working memory, and
perceptual switching in optical illusions are all examples of pattern
formation that can be modelled by such a theory. Refer to Bressloff 2012
@Bressloff2012a for a comprehensive review.</p>
<p>The addition of additive noise to the above model:</p>
<div>
$$dU=\left[-U+\int_{-\infty}^{\infty}w(x-y)F(U(y,t))dy\right]dt+g(U)dW(x,t)\label{eq:neuralfield}$$
</div>
<p>for $dW(x,t)$ a white noise process has been studied by Bressloff
from both a path integral approach, and by studying a
perturbation expansion of the resulting master equation more directly.
We describe briefly how the path integral approach is formulated, and
the results that can be computed as a result. More details are found in
Bressloff 2009.</p>
<p>As above, this is discretized in both time and space to give:</p>
<div>
$$U_{i+1,m}-U_{i,m}=\left[-U_{i,m}+\Delta d\sum_{n}w_{mn}F(U_{i,n})\right]\Delta t+\frac{\sqrt{\Delta t}}{\sqrt{\Delta d}}g(U_{i,m})dW_{i,m}+\Phi_{m}\delta_{i,0}$$
</div>
<p>for initial condition function $\Phi(x)=U(x,0).$ Where each noise
process is a zero-mean, delta correlated process:</p>
<div>
$$\langle dW_{i,m}\rangle=0,\quad\langle dW_{i,m}dW_{j,n}\rangle=\delta_{i,j}\delta_{m,n}.$$
</div>
<p>Let $U$ and $W$ represent vectors with components $U_{i,m}$ and
$W_{i,m}$ such that we can write down the probability density function
conditioned on a particular realization of $W$:</p>
<div>
$$P(U|W)=\prod_{n}\prod_{i=1}^{N}\delta\left(U_{i+1,m}-U_{i,m}+\left[U_{i,m}-\Delta d\sum_{n}w_{mn}F(U_{i,n})\right]\Delta t-\frac{\sqrt{\Delta t}}{\sqrt{\Delta d}}g(U_{i,m})dW_{i,m}-\Phi_{m}\delta_{i,0}\right)$$
</div>
<p>where we again use the Fourier representation of the delta function:</p>
<div>
$$P(U|W)=\int\prod_{n}\prod_{i=1}^{N}\frac{d\tilde{U}_{j,n}}{2\pi}\exp\tilde{-iU_{i,m}}\left(U_{i+1,m}-U_{i,m}+\left[U_{i,m}-\Delta d\sum_{n}w_{mn}F(U_{i,n})\right]\Delta t-\frac{\sqrt{\Delta t}}{\sqrt{\Delta d}}g(U_{i,m})dW_{i,m}-\Phi_{m}\delta_{i,0}\right).$$
</div>
<p>Knowing the density for the random vector $W$ we can write the
probability of a vector $U$:</p>
<div>
$$P(U)=\int\prod_{n}\prod_{i=1}^{N}\frac{d\tilde{U}_{j,n}}{2\pi}\exp\tilde{-iU_{i,m}}\left(U_{i+1,m}-U_{i,m}+\left[U_{i,m}-\Delta d\sum_{n}w_{mn}F(U_{i,n})\right]\Delta t+\frac{\Delta t}{2\Delta d}g^{2}(U_{i,m})\tilde{U}_{i,m}-\Phi_{m}\delta_{i,0}\right).$$
</div>
<p>Taking the continuum limit gives the density:</p>
<div>
$$P[U]=\int\mathcal{D}\tilde{U}e^{-S[U,\tilde{U}]},$$
</div>
<p>for action</p>
<div>
$$S[U,\tilde{U}]=\int dx\int_{0}^{T}dt\tilde{U}\left[U_{t}(x,t)+U(x,t)-\int w(x-y)F(U(y,t))dy-\Phi(x)\delta(t)-\frac{1}{2}\tilde{U}^{2}g^{2}(U(x,t))\right].$$
</div>
<p>Given the action, the moment generating functional and propagator can be
defined as previously. In linear cases the moments can be computed
exactly.</p>
<h3 id="the-weak-noise-expansion">The weak-noise expansion</h3>
<p>If the noise term is scaled by a small parameter, $g(U)\to\sigma g(U)$
for $\sigma\ll1.$ (For instance, in the case of a Langevin approximation
to the master equation, it is the case that $\sigma\approx1/N$ for $N$
the number of neurons.) Rescaling variables
$\tilde{U}\to\tilde{U}/\sigma^{2}$ and
$\tilde{J}\to\tilde{J}/\sigma^{2}$ then the generating functional
becomes:</p>
<div>
$$Z=\int\mathcal{D}U\mathcal{D}\tilde{U}e^{-\frac{1}{\sigma^{2}}S[U,\tilde{U}]}e^{\frac{1}{\sigma^{2}}\int dx\int_{0}^{T}dt[\tilde{U}J+\tilde{J}U]},$$
</div>
<p>which can be thought of in terms of a loop expansion described above. Performing the expansion in orders of
$\sigma$ allows for a ‘semi-classical’ expansion to be performed. The
corrections to the deterministic equations take the form</p>
<div>
$$\frac{\partial v}{\partial t}=-v(x,t)+\int w(x-y)F(v(y,t))dy+\frac{\sigma^{2}}{2}\int w(x-y)C(x,y,t)F''(v(y,t))dy+O(\sigma^{4})$$
</div>
<p>for $C(x,y,t)$ the second-order cumulant (covariance) function. The
expression for $C(x,y,t)$ is derived and studied in more detail in Buice
<em>et al</em> 2010.</p>
<h2 id="mean-field-wilson-cowan-equations-and-corrections">Mean-field Wilson-Cowan equations and corrections</h2>
<p>Another approach using path integrals has been extensively studied by
Buice and Cowan (Buice2007, see also Bresslof
2009). Here, we envision a network of neurons which exist
in one of either two or three states, depending on the time scales of
interest relative to the time scales of the neurons being studied. Each
neuron in the network is modeled as a Markov process which transitions
between active and quiescent states (and refractory, if it’s relevant).</p>
<p>For the two state model, assume that each neuron in the network creates
spikes and that these spikes have an impact on the network dynamics for
an exponentially distributed time given by a decay rate $\alpha.$ Let
$n_{i}$ denote the number of ‘active’ spikes at a given time for neuron
$i$ and let $\mathbf{n}$ denote the state of all neurons at a given
time. We assume that the effect of neuron $j$ on neuron $i$ is given by
the function</p>
<div>
$$f(\sum_{ij}w_{ij}n_{j}+I)$$
</div>
<p>for some firing rate function
$f$ and some external input $I$. Then the master equation for the state
of the system is:</p>
<div>
$$\frac{dP(\mathbf{n},t)}{dt}=\sum_{i}\alpha(n_{i}+1)P(\mathbf{n}_{i+},t)-\alpha n_{i}P(\mathbf{n},t)+f\left(\sum_{ij}w_{ij}n_{j}+I\right)[P(\mathbf{n}_{i-},t)-P(\mathbf{n},t)]$$
</div>
<p>where we denote by \(\mathbf{n}_{i\pm}\) the state of the network
\(\mathbf{n}\) with one more or less active spike in neuron $i$. The
assumption is made that each neuron is identical and that the weight
function \(w_{ij}=w_{|i-j|}\), that is, it only depends on the distance
between the two neurons. Of interest is the mean activity of neuron $i$:</p>
<div>
$$a_{i}(t)=\langle n_{i}(t)\rangle.$$
</div>
<p>Using an operator representation it is possible to derive a stochastic
field theory in the continuum limit ($N\to\infty$ and
$n_{i}(t)\to n(x,t)$) to give moments of $n_{i}(t)$ in terms of the the
interaction between two fields $\varphi(x,t)$ and
$\tilde{\varphi}(x,t)$. The details of the derivation are contained in
the Appendices of Buice and Cowan 2007. These fields can be
related to quantities of interest through</p>
<div>
$$a(x,t)=\langle n(x,t)\rangle=\langle\varphi(x,t)\rangle$$
</div>
<p>and</p>
<div>
$$\langle n(x_{1},t_{1})n(x_{2},t_{2})\rangle=\langle\varphi(x_{1},t_{1})\varphi(x_{2},t_{2})\rangle+\langle\varphi(x_{1},t_{1})\tilde{\varphi}(x_{2},t_{2})\rangle a(x_{2},t_{2})$$
</div>
<p>for $t_{1}>t_{2}$. The propagator, as before, is</p>
<div>
$$G(x_{1},t_{1};x_{2},t_{2})=\langle\varphi(x_{1},t_{1})\tilde{\varphi}(x_{2},t_{2})\rangle$$
</div>
<p>and the generating function is given by</p>
<div>
$$Z[J,\tilde{J}]=\int\mathcal{D}\varphi\mathcal{D}\tilde{\varphi}e^{-S[\varphi,\tilde{\varphi}]+J\tilde{\varphi}+\tilde{J}\varphi}.$$
</div>
<p>For the master equation above the action is given by:</p>
<div>
$$S[\varphi,\tilde{\varphi}]=\int dx\left(\int_{0}^{t}dt\tilde{\varphi}\partial_{t}\varphi+\alpha\tilde{\varphi}\varphi-\tilde{\varphi}f\left(w\star[\tilde{\varphi}\varphi+\varphi]+I\right)\right)-\int dx\,\bar{n}(x)\tilde{\varphi}(x,0),$$
</div>
<p>for convolution $\star$ and initial condition vector $\bar{n}(x).$ This
now allows the action to be divided into a free and interacting action
and for perturbation expansions to be performed.</p>
<p>The loop expansion provides a useful expansion and, as described in
Section 2, amounts to ordering Feynman diagrams by the number of loops
contained in them. The zeroth order, mean field theory, corresponds to
Feyman diagrams containing zero loops. Such diagrams are called tree
diagrams. It can be shown that the dynamics of this expansion obey:
\(\partial_{t}a_{0}(x,t)+\alpha a_{0}(x,t)-f(w\star a_{0}(x,t)+I)=0\)
which are also a simple form of the well known Wilson-Cowan equations.
That these equations are recovered as the zeroth order expansion of the
continuum limit of the master equation gives confidence that the
higher-order terms of the expansion will indeed correspond to relevant
dynamics. The ‘one-loop’ correction is given by:</p>
<div>
$$\partial_{t}a_{1}(x,t)+\alpha a_{1}(x,t)-f(w\star a_{1}(x,t)+I)+h\mathcal{N}(a_{1},\Delta)=0$$
</div>
<p>for</p>
<div>
$$\mathcal{N}(a,\Delta)=\int dx_{1}dx_{2}dx'dt'dx''f^{(2)}(x,t)w(x-x_{1})w(x-x_{2})f^{(1)}(x',t')w(x'-x'')\Delta(x_{1}-x',t-t')\Delta(x_{2}-x'',t-t')a(x'',t')$$
</div>
<p>and the ‘tree-level’ propagator</p>
<h1 id="summary">Summary</h1>
<p>We have described how path integrals can be used to compute moments and
densities of a stochastic differential equation, and how they can be
used to perform perturbation expansions around ‘mean-field’, or
classical, solutions.</p>
<p>Path integral methods, once one is accustomed to their use, can provide
a quick and intuitive way of solving particular problems. However, it is
worth highlighting that there are few examples of problems which can be
solved with path integral methods but not with other, perhaps more
standard, methods. Thus, while they are a powerful and general tool,
their utility is often countered by the fact that, for many problems,
simpler solution techniques exist.</p>
<p>Further, it should be highlighted that the path integral as it was
defined here – as a limit of finite-dimensional integration
($\int\prod_{i}^{N}dx_{i}\to\int\mathcal{D}x(t)$) – does not result in a
valid measure. In some cases the Weiner measure may equivalently be
used, but in other cases the path integral as formulated by Feynman
remains a mathematically unjustified entity.</p>
<p>With these caveats in mind, their principle benefit, then, may instead
come from the intuition that they bring to novel mathematical and
physical problems. When unsure how to proceed, having as many different
ways of approaching a problem can only be beneficial. Indeed, in 1965
Feynman said in his Nobel acceptance lecture: “Theories of the known,
which are described by different physical ideas may be equivalent in all
their predictions and are hence scientifically indistinguishable.
However, they are not psychologically identical when trying to move from
that base into the unknown. For different views suggest different kinds
of modifications which might be made and hence are not equivalent in the
hypotheses one generates from them in one’s attempt to understand what
is not yet understood.”</p>
<p></div></p>
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:3" role="doc-endnote">
<p><em>e.g.</em> in QED this coupling is related to change of electron
($e$): $\alpha\approx1/137=\text{fine structure constant}$ <a href="#fnref:3" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
<li id="fn:4" role="doc-endnote">
<p>The expression for the mean and variance I was able to verify (pp.
83-85 @Gitterman2005). The expression for the covariance I was
unable to locate in another source to verify; that it reduces to the
correct variance is encouraging, however. <a href="#fnref:4" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>Ben Lansdellben dot lansdell at gmail dot comIn the previous post we defined path integrals through a simple ‘time-slicing’ approach. And used them to compute moments of simple stochastic DEs. In this follow-up post we will examine how expansions can be used to approximate moments, how we can use the moment generating functional to compute probability densities, and how these methods may be helpful in some cases in neuroscience.