Let $\mu$ be a probability distribution on $\mathbb R^d$ with "sufficiently regular" density $p$. Let $f:\mathbb R^d \to \mathbb R$ be a "sufficiently regular" function. Finally, for every $t \ge 0$, define
$$
s\_f(t) := \mu(f^{-1}((-\infty,t])) = \int\_{f^{-1}((-\infty,t])}p(x)dx
$$



> 
> **Question.** *What is the derivative of $s\_f$ w.r.t $t$ ?*
> 
> 
> 


It seems I should be able to solve my problem in principle using Lemma 3.1 of [Malliavin Calculus for non Gaussian differentiable measures and surface measures in Hilbert spaces](https://arxiv.org/abs/1608.05964). However, that paper is hard to parse for a non-expert like myself.




---


Now, suppose $f$ depends "smoothly" on a parameter $\theta$, i.e let $\Theta$ be a nonempty subset of some $\mathbb R^n$ and suppose $F:\mathbb R^d \times \Theta \to \mathbb R$ is "smooth", and for any $\theta \in \Theta$, define $s\_\theta := s\_{f\_\theta}$, where $f\_\theta(x):=F(x,\theta)$ for all $x \in \mathbb R^d$.



> 
> **Question.** *For every $t \ge 0$, what is the gradient of $\theta \mapsto s\_\theta(t)$.*
> 
> 
> 


Examples
--------


* *Linear:* $f(x) = w^\top x - c$, for some unit-vector $w \in \mathbb R^d$ and scalar $c \in \mathbb R$. Here $\theta = (w,c) \in \mathbb R^{d + 1}=:\Theta$.
* *Quadratic:* $f(x) = \pm (r^2-\|x\|^2)$, here $\theta = r^2 \in (0,\infty) =: \Theta$.



Time-derivative of integral over sub-level set $s(t) := \int_{f^{-1}((-\infty,t])}p(x)dx$
This is a comment (but too long for that format) to suggest a simple and elementary approach: we can write
$$s\_f(t)=\int H(t-f(x))p(x)\,dx$$ and manipulate formally (but see below) to get
$$\frac{d}{dt}s\_f(t)=\int \delta(t-f(x))p(x)\,,dx$$ where $H$ and $\delta$ are the Heaviside function and the Dirac distribution respectively. This suggests using the elementary theory of distributions for your computations, which can then be carried out in the concrete situations you describe using well-established formulae.


Similarly, if $$s\_{\theta}(t)=\int H(t-f(x,\theta))p(x)\,dx,$$ we can compute its partial derivatives with respect to the parameters as
$$\int \delta(t-f(x,\theta))\frac{\partial}{\partial \theta\_i}f(x,\theta)\,p(x)\,dx.$$


Note that in order to make this rigorous, one requires, within the context of distribution theory, the notions of parametrised integrals, differentiation under the integral sign, composition of a distribution with a smooth function (and the chain rule) and the product of a smooth function and a distribution. All of these are standard fare (they were developed by a cohort of prominent mathematicians in the 50´s and 60´s, together with methods for explicit computations for concrete functions--all this at the level of a first year analysis course). The two examples for $f$ that you mention are particularly simple.


In case of interest, I would be happy to include references.


