Maths Bio - small gene circuits/law of mass action 
As a summary, I'm looking at this binding reaction:
$$O_0 + X_2 \rightleftharpoons O_1 $$
where $O_0$ is a state of unbound promoter and $O_1$ is a state of bound promoter. The forward and backward rate of reactions are $k$ and $\beta k$ respectively.
Then if $p$ is the probability that the state is bound, we have
$$\frac{dp}{dt} = kx_2 (1 - p) - \beta k p$$
where $x_2$ is the concentration of the dimer $X_2$

Question 1: how is the equation for $\frac{dp}{dt}$ derived? I know that $kx_2$ is the rate of the forward chemical reaction by mass-action, but I'm not too sure on the rest?
Question 2: my lecture notes say that the fraction of the time spent in the state $0$ is the time average of $p$. Firstly, what do they mean by the time average? Secondly, why is this the case?
Thank you.
 A: The equation $$ \frac{dp}{dt} = kx_2(1-p) - \beta kp $$
means that the association follows the law of mass action, but that the dissociation does not. In other words, the probability of a given molecule binding depends on the concentration of $X_2$, but the probability of unbinding does not depend on that concentration (nor on that of the bound state). Instead, once bound, the rate of dissociation is a random event with rate $\beta k$ that is simply "fixed". The dissociation behaviour is something empirical usually; i.e., some molecules will dissociate in a random event independent of concentrations (like here), others will dissociate slower if the concentration of unbound dimers is higher, etc...  
Here's one way to see it. First, $p$ governs a time-dependent Bernoulli random variable, $s_t \sim \text{Bern}(p(t))$, where $s_t=1$ in the bound state, and $s_t=0$ in the unbound state. Recall, $p(t)$ is the probability of being in the bound state at time $t$. (So $s_t=1$ if we are in the bound state at time $t$). Consider a time period, from $t=0$ to $t=T$. How much time do we spend in the bound state? Well, we need to add up all the time that $s_t = 1$ and divide by $T$. This is the proportion of time $s_t=1$ (i.e., we are in the bound state) in $T$-length of time. Since we assume $s_t$ to be continuously changing, this means integrating over it (this is the time average of $s_t$ over $T$ time)
$$ A = \frac{1}{T}\int_0^T s_t\, dt $$ 
But we cannot (nor want to) really evaluate this because it is a single random trajectory. If you perform the same "experiment" $n$ times (i.e., measure the time spent in the bound state over $T$ seconds), you will get a different result each time. We don't want that: we want the average over many experiments. In fact, we want the expected value of $A$, which is the equivalent of taking $n\rightarrow\infty$, informally speaking. 
Basically, the fraction of time spent in the bound state is given by
$$
\mathbb{E}[A] = \mathbb{E}\left[ \frac{1}{T}\int_0^T s_t\, dt \right]
= \frac{1}{T}\int_0^T \mathbb{E}[s_t] \, dt
= \frac{1}{T}\int_0^T p(t) \, dt
$$
which is exactly the time average of $p$.
