
\documentclass[a4paper,12pt,finnish]{article}
\usepackage{hyperref}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{unicode}
\usepackage{multicol}
%\usepackage[geometry]{ifsym}
\usepackage[finnish]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{verbatim}
%\usepackage{html,makeidx}
\usepackage{eurosym}
\def\eu{\mbox{\euro}}
\def\R{\mathbb{R}}
\def\Q{\mathbb{Q}}
\def\N{\mathbb{N}}
\def\E{\mathbb{E}}
\def\Z{\mathbb{Z}}
\def\P{\mathbb{P}}
\def\T{\mathbb{T}}
\def\F{\mathbb{F}}

\def\indep{\perp\!\!\perp}
%\def\mathcal{\cal}
\def\ind{\mathrel{\hbox{\rlap{\hbox to 7.5pt{\hrulefill}}\raise6.6pt\hbox{\eka\char'167}}}}
\newtheorem{thm}{Teoreema}[section]
\newtheorem{rmk}{Huomautus}[section]
\newtheorem{lemma}{Lemma}[section]
\newtheorem{propo}{Lause}[section]
\newtheorem{coro}{Seuraus}[section]
\newtheorem{assu}{Oletus}[section]
\newtheorem{har}{Tehtävä}[section]
\newtheorem{ex}{Esimerkki}[section]
\newtheorem{define}{Määritelmä}[section]
\numberwithin{equation}{section}

\def\Tau{{\mathcal T}}


\begin{document}{\bf UH Malliavin Calculus, Fall 2016, Exercises 1-2 (14 and 21.9 2016) }

\begin{enumerate}

\item Let $G(\omega) \sim {\mathcal N}(0,1)$ be a standard Gaussian random variable, with probability density
\begin{align*}
  \phi(x) =  \frac 1 {\sqrt{2\pi} }  \exp\biggl( - \frac {x^2} 2 \biggr), \quad x \in \R
\end{align*}
Since we know that $E_P\biggl( \exp( \lambda G^2 /2 ) \biggr)< \infty$  $\forall \lambda < 1$,
and when $0< \lambda< 1$, for any polynomial $p(x)$, there are constants $C_1,C_2$ such that
\begin{align*}
  |p(x)| \le C_1 + C_2 \exp( \lambda x^2/ 2)
\end{align*}
which implies  that $E_P ( | G |^p ) < \infty$   and $G\in L^p(P)$  for all exponents $p>0$.
Similarly all exponential moments $E_P\bigl( \exp( t G) \bigr)= \exp( t^²/2 )$ are finite $\forall t\in \R$.
Note also that
the standard Gaussian distribution is symmetric around the origin, with $\phi(x)=\phi(-x)$.

\begin{enumerate}
\item
Use symmetry  to show that  $\forall  n\in \N$   we have $E_P(G^{2n+1})=0$ for all the odd moments.


\if 0
{\bf Solution}
\begin{align*} &
  \int_{R}  x^{2n+1}  \phi(x) dx = \int_{-\infty}^0  x^{2n+1}  \phi(x) dx + \int_0^{\infty}  x^{2n+1}  \phi(x) dx
 & \\ & =  \int_{-\infty}^0 x^{2n+1}  \phi(-x) dx + \int_0^{\infty}  x^{2n+1}  \phi(x) dx
& \\ & =  -\int_0^{\infty}  x^{2n+1}  \phi(x) dx  + \int_0^{\infty}  x^{2n+1}  \phi(x) dx = 0
&  \end{align*}
where $\int_0^{\infty} x^{2n+1} dx < \infty$  since $E_P( |G|^{2n+1} ) < \infty$.
\fi

\item
Compute $E_P( G^2)$.  

{\bf Hint}
You can use the Gaussian integration by parts formula $E_P( f(G) G) = E_P( f^'(G) )$  after checking
the integrability condition.
Equivalently you can use the property of the standard Gaussian density $\partial_x \phi(x)=  -\phi(x) x$ and use
the usual integration by parts formula.

\if 0
{\bf Solution }  For $f(x)=x$ with $f^'(x)=1$ we obtain $E_P( G^2) = E_P(G G ) = E_P( f(G)G)=E_P( f'(G) ) = E_P( 1 ) = 1$.
\fi

\item  Use induction to compute the even moments of the standard Gaussian $E_P( G^{2n} )$, for $n\in \N$.

\if 0
{\bf Solution } For $f(x)=x^{2n-1}$ with  $f'(x)=(2n-1) x^{2n-2}$
, 
\begin{align*} &
E_P( G^{2n} ) = E_P( G^{2n-1} G) = E_P( f(G) G) = E_P( f'(G) )=(2n-1) E_P( G^{2(n-1) })=
& \\ &
 (2n-1)(2n-3)  E_P( G^{2(n-2)})= \dots
 & \\ &= (2n-1) \times (2n-3) \times (2n-5) \times \dots  \times 7 \times  5 \times 3 \times 1 :=(2n-1)\!\!
  &\end{align*}
\fi 
\end{enumerate}

\item  For $t\in \R$ compute the expectations:

\begin{enumerate}
\begin{multicols}{3}
\item $E_P\bigl( G {\bf 1}( G > t) \bigr)$
\item  $E_P\bigl( G {\bf 1}( G \le t) \bigr)$
\item $E_P\bigl( G^2 {\bf 1}( G >  t) \bigr)$
\columnbreak
\item  $E_P\bigl( G^2 {\bf 1}( G \le t) \bigr)$
\item  $E_P\bigl( G^3 {\bf 1}( G > t) \bigr)$
\item  $E_P\bigl( G^3 {\bf 1}( G \le t) \bigr)$
\columnbreak
\item  $E_P\bigl( G^4 {\bf 1}( G > t) \bigr)$
\item  $E_P\bigl( G^4 {\bf 1}( G \le t) \bigr)$
\end{multicols}
\end{enumerate} 
Hints: Show you can use the Gaussian integration by part formula $E_P( f(G)G)=E_P( f^'(G) )$
 with $f(x)={\bf 1}( x > t)$.  In this case $f^'(x)= \delta_t(x)=\delta_0(x-t)$ is not a function but a generalized function (a distribution in analysis language),
 the Dirac-delta function at $t$, with the defining property
 \begin{align*}
 g(t)=  \int_{\R}  g(x) \delta_t(x) dx = \int_{\R} g(x)\delta_0(x-t)dx=\int_{\R} g(y+t) \delta_0(y)dy
 \end{align*}
for any continuous test function  $g$ with compact support. From the probabilistic
point of view the measure  $\mu(dx)=\delta_t(x)dx$ is simply  the probability measure 
of a deterministic random variable concentrated in the singleton $\{ t \}$.

In order show that the integration by parts formula is correct also in this case,
approximate  the indicator $f(x)={\bf 1}( x > t)$ by the sequence
$f_n(x)=  \bigl( (x-t)^+ n ) \wedge 1$  which satisfies $0\le f_n(x) \le f(x) \le 1 $ $\forall x$,
and it is piecewise linear with derivative $f_n^'(x)= n {\bf 1}\bigl(  t < x \le t+ 1/n  \bigr)$.

Apply the Gaussian integration by parts  to $f_n(x)$ and use the dominated convergence Theorem to take limits.

\if 0
{\bf Solution} 
a) Formally for $f(x)= {\bf 1}( x > t)$ with $f^'(x)=\delta_t(x)$
 \begin{align*} &
E_P( G {\bf 1}( G > t) ) =  E_P( G f(G) )=E_P( f'(G) ) = E_P( \delta_t(G) ) = \int_{\R} \delta_t(x) \phi(x) dx 
& \\ &= \phi(t) = \frac 1 {\sqrt{2\pi}} 
\exp\bigl( - \frac{ t^2} 2 \bigr)
&\end{align*}
However this is a bit suspicious, since $\delta_t(x)$ is not a function (it is a generalized function in the sense of distribution).
We show that the formula is correct indeed.
We just apply the Gaussian integration by parts to $f_n(x)$.
\begin{align*}
  E_P(  G f_n(G) ) = E_P( f^'_n(G) ) = n P\bigl( G \in (t,t+1/n] \bigr) = n \int_t^{t+1/n} \phi(x) dx
\end{align*}
   Note that $\forall \omega\in \Omega$,
   $ G(\omega)f_n(G(\omega)) \to G(\omega) f(G(\omega) )$
   and  $ |G(\omega)f_n(G(\omega)) \le |G(\omega)| \in L^1(P)$
and by Lebesgue dominated convergence Theorem it follows that
\begin{align*}
   E_P( G f_n(G ) ) \to E_P( G f(G))
\end{align*}
on the other hands, since $x\mapsto \phi(x)$ is continuous,
\begin{align*} \lim_{n\to\infty }  E_P( f^'_n(G) ) =
 \lim_{n\to\infty }  n \int_t^{t+1/n} \phi(x) dx = \phi(t) = E_P( \delta_t (G) )
\end{align*}

b) $E_P\bigl( G {\bf 1}( G \le t) \bigr)= E_P( G) -E_P\bigl( G {\bf 1}( G > t) \bigr)= 0 - \phi(t)$

c) $E_P\bigl( G^2 {\bf 1}(G > t) \bigr) = E_P\bigl( G  G {\bf 1}(G > t) \bigr) =  E_P\bigl( G f(G) \bigr) =E_P\bigl(f^'(G) \bigr) $
where $f(x) = x{\bf 1}( x > t)$ with derivative  ${\bf 1}( x> t) + x \delta_t(x) $.
giving
\begin{align*}
  E_P\bigl( G^2 {\bf 1}(G > t) \bigr) = E_P( {\bf 1}( x > t ) ) + E_P\bigl( x \delta_t(x) \bigr)=  1- \Phi(t) + t \phi(t)=  \Phi(-t) + t \phi(t)
\end{align*}
where $\Phi(t)= \int_{\infty}^t \phi(x) dx = P( G \le t)$
is the cumulative distribution function of the Gaussian distribution. By symmetry $P( G > t)=1-\Phi(t)= P( G \le -t)=\Phi(-t)$.

d) \begin{align*}
     E_P\bigl( G^2 {\bf 1}(G \le  t) \bigr) = E_P( G^2) -  E_P\bigl( G^2 {\bf 1}(G > t) \bigr) = \Phi(t) -t \phi(t)
   \end{align*}
e)
\begin{align*}
   E_P\bigl( G^3 {\bf 1}(G > t) \bigr) = E_P\bigl( G  G^2 {\bf 1}(G > t) \bigr) = E_P( f^'(G) )
\end{align*}
where $f(x)= x^2 {\bf 1}( x> t)$ with derivative $2 x {\bf 1}( x > t) $ + $x^2 \delta_t(x)$
\begin{align*}
  = 2 E_P( G {\bf 1}( G > t) ) + E_P( G^2 \delta_t(G) ) = (2+ t^2) \phi(t)   
\end{align*}

f)  \begin{align*}
     E_P\bigl( G^3 {\bf 1}(G \le  t) \bigr) = E_P( G^3) -  E_P\bigl( G^2 {\bf 1}(G > t) \bigr) = -(2+t^2) \phi(t)
   \end{align*}
 \fi 
 
 

\item
Let $H\subset  L^2(\Omega,{\mathcal F},P)$ be a closed (with respect to the $L^2$ norm) subspace of random variables, and $X\in L^2(P)$.
There exists an element $Y\in H$ which minimizing the $L^2$ distance from $X$ among all $H$ elements.
\begin{align*}
    E_P\bigl(  ( Y-X)^2 \bigr) \le  E_P\bigl(  ( V-X)^2 \bigr) \quad  \forall V\in H 
\end{align*}
It is also true that $(Y-X) \perp H$,  (  $(X-Y)$ is orthogonal to $H$ ),
equivalently 
\begin{align*}
E_P( Y V )=E_P( X V)  \quad  \forall  V\in H
\end{align*}


We denote $\Pi_H X = Y$ as the orthogonal projection of $X$ into the subspace $H$.

For example if ${\mathcal G}\subseteq {\mathcal F}$ is a sub $\sigma$-algebra,
$H=L^2( \Omega,{\mathcal G},P)$ is a closed subspace of $L^2( \Omega,{\mathcal G},P)$
and in this case $\Pi_H X $ coincides with the conditional expectation $E_P( X | {\mathcal G})$.

\begin{enumerate} 

\item Show that the  $L^2$-projection $\Pi_H$ 
is a  linear operator: when $X, Z\in L^2(P),\; a,b\in \R$,
\begin{eqnarray*} 
\Pi_H (a X+ bZ)=  a\Pi_H X + b\Pi_H Z,
\end{eqnarray*} 
\item
Show that the $L^2$ projection is idempotent :    $(\Pi_H)^2 =\Pi_H)$, meaning that when $Y\in H$, $\Pi_H Y= Y$,
\item Show that  the projection does not increase the $L^2$ norm:
\begin{align*}
\parallel X\parallel_{L^2(P)} \ge\parallel \Pi_H X\parallel_{L^2(P)}\end{align*}
\end{enumerate}
These properties characterize projection operators. 


{\bf The Next exercises are about combining the idea of taking $L^2(P)$-projections to the linear
 span subspace of $L^2(P)$ random variable, together with the integration by parts formula
 for Gaussian, Poisson, and Bernoulli variables.} 

 
 
 
\if 0
\item
When $G(\omega)\sim N(0,1)$ is a standard Gaussian variable with probability density
$\phi(y)= (2\pi)^{-1/2} \exp\bigl( - y^2/ 2 \bigr)$, and $\mu,\sigma\in R$, we say that
$X(\omega)=\mu + \sigma G(\omega)$ has the Gaussian density ${\mathcal  N}( \mu, \sigma^2)$
with mean $\mu=E(X)$ and variance $\sigma^2= E_P(X^2)-E_P(X)^²$

Compute the  density of $X(\omega)$. \fi

\item Let $G(\omega)\sim N(0,1)$ be a standard Gaussian variable with probability density
$\phi(y)= (2\pi)^{-1/2} \exp\bigl( - y^2/ 2 \bigr)$,
and let  $f(x)$ be a differentiable function with $E_P(f(G)^2)<\infty$ and  $E_P( |f^'(G) |)<\infty$.

\begin{enumerate} \item
Use the Gaussian integration by parts formula to show that
\begin{align*}
  \widehat f(G) = E_P(f(G) ) + E_P( f^'(G) ) G(\omega)
\end{align*}
is the  best linear approximation of $f(G)$ based in the closed linear span of $\{ 1, G(\omega)\}$ in least square sense,
meaning that $\widehat a = E_P(f(G))$ and $\widehat b=E_P( f^'(G) )$ are
minimizing the mean square error
\begin{align*}
      E_P(   \bigl\{  f(G) - ( a+ b G) \bigr\}^2 \bigr)  , \quad a,b\in \R
\end{align*}
\item 
Now we consider the same linear approximation in the multivariate case.
where we  use the following extension of the linear predictor formula from Example 9.1.1. in the lecture notes:

When $X(\omega)=(X_1(\omega),\dots, X_T(\omega) )\in L^2( \Omega,{\mathcal F},P)$,
then the following multivariate formula holds: for $Y=(Y_1,\dots,Y_d)$ is another random variable in $L^2(P)$,
\begin{align*} 
  \widehat Y =E_P(Y) + (X-E_P(X) )  \mbox{Cov}(Y,Y)^{-1} \mbox{Cov}( X,Y)
\end{align*}
where $M^{-1}$ denoted the inverse of a matrix $M$ and $\mbox{Cov}( X,Y)_{ij}=E( X_i Y_j )-E(X_i)E(X_j)$ is 
the covariance between $X_i$ and $Y_j$,

and $\widehat Y_i$ is the $L^2(P)$-projection of $Y_i$  to the linear span of $\{ 1, X_1,\dots, X_d\}$.













Let $G(\omega)=(G_1(\omega),\dots, G_T(\omega))\in \R^T$  where the coordinates $G_t(\omega)$ are 
  independent and identically distributed standard Gaussian random variables.
  Let $f:\R^T  \to \R$ be differentiable with $E_P\bigl( f(G_1,\dots G_n)^2 \bigr)<\infty$ and
  \begin{align*}
    E_P\biggl( \bigg\vert\frac {\partial  }{ \partial x_t} f(G_1,\dots, G_T) \biggr\vert \biggr) < \infty    
  \end{align*}
Show that
\begin{align*}
  \widehat f(G_1,\dots, G_T) = E_P( f(G_1,\dots, G_T) ) +\sum_{t=1}^T  E_P\biggl( \frac {\partial  }{ \partial x_t} f(G_1,\dots, G_T) \biggr) G_t
\end{align*}
is the best linear approximation of $f(G_1,\dots,G_T)$ in the linear span of $\{ 1,G_1,\dots,G_T \}$.
  with coefficients minimizing the mean square error 
  \begin{align*}
      E_P\biggl(   \biggl\{  f(G_1,\dots,G_T) - \biggl( c_0 + \sum_{t=1}^T c_t G_t \biggr) \biggr\}^2 \biggr) 
\end{align*}
  
  \item Next
we consider the correlated case: let $A=( A_{st} )$ be a non-singular $T\times T$
matrix, $G=(G_1,\dots,G_T)$ with i.i.d. standard Gaussian coordinates as before and let $X=(X_1,\dots,X_T)= AG^{\top}$ 
with coordinates 
\begin{align*}
  X_s = \sum_{t=1}^T  A_{st} G_t
\end{align*}
We have seen that the random vector $X$ is Gaussian with zero mean and covariance matrix $\Sigma= A A^{\top}$.
Let $f(x_1,\dots,x_T)$ be a differentiable function with
\begin{align*}
  E_P( f(X_1, \dots,X_T)^2 ) <\infty 
\end{align*}
and 
 \begin{align*}
    E_P\biggl( \bigg\vert\frac {\partial  }{ \partial x_t} f(X_1,\dots, X_T) \biggr\vert \biggr) < \infty    
  \end{align*}
  Compute the coefficients of the best linear approximation $\widehat f(X_1,\dots,X_T)$  of $f(X_1,\dots,X_T)$ in 
  the linear span of $\{ 1, X_1,\dots,X_T\}$ minimizing the mean square error
   \begin{align*}
      E_P\biggl(   \biggl\{  f(X_1,\dots,X_T) - \biggl( c_0 + \sum_{t=1}^T c_t X_t \biggr) \biggr\}^2 \biggr) 
\end{align*}
  \end{enumerate}
  
  
  \item  
  Let $N(\omega)$ be a Poisson$(\lambda)$ distributed random variable with parameter $\lambda>0$.
   where 
   \begin{align*}
   P_{\lambda}\bigl( N=k \bigr) =  \exp(- \lambda  ) \frac{ \lambda^k}{ k!}  \quad \mbox{ for  }  k \in \N \; .
  \end{align*}
 and $( f(k):k\in \N)$ a sequence with $E( f(N)^2)<\infty$.
 \begin{enumerate}
 
 \item 
Prove the Stein equation or integration by parts formula for Poisson-$\lambda$ random variables:
\begin{align*}
  E_{\lambda}\bigl( f(N) N  \bigr) = \lambda E_{\lambda}\bigl( f(N+1) \bigr)
\end{align*}

\item  Use the integration by parts formula for Poisson random variable to compute the first Poisson moments.
$E_{\lambda}( N)= \lambda$,   $E_{\lambda}( N^2)= \lambda^2+ \lambda$.


 \item 
 Show that
 \begin{align*}
       \widehat f(N)= E_{\lambda}( f(N) ) +   E_{\lambda}( f(N+1) -f(N) ) (N-\lambda)
 \end{align*}
is the best linear estimator of $f(N)$ depending on $N$  on the closed linear span of $\{ 1, N(\omega) \}$, with coefficients minimizing 
the mean square error
\begin{align*}
      E_P(   \bigl\{  f(N) - ( a+ b N) \bigr\}^2 \bigr) 
\end{align*}

\item 
Let now 
Let $N(\omega)=(N_1(\omega),\dots, N_T(\omega))\in \N^T$  where the coordinates are 
   $N_t(\omega)$ are independent and Poisson$(\lambda_t)$ distributed for $t=1,\dots,T$, respectively,
   with $\lambda_t >0$ (possibly different).
   
   
   Let $f: \N^T \to [0,+\infty)$ be a function with $E_P( f(N_1,\dots,N_T)^2 ) <\infty$.

Show that {\footnotesize
\begin{align*}  &
  \widehat f(N_1,\dots, N_T) =  E_P( f(N_1,\dots, N_T) ) + & \\ &
  \sum_{t=1}^T  E_P\biggl(  f( N_1,\dots,N_{t-1}, 1+ N_t,N_{t+1}\dots, N_T) -f(N_1, 
  \dots,N_{t-1}, N_t,N_{t+1}\dots,          , N_T)  \biggr) 
  \bigl( N_t - \lambda_t)&
\end{align*} }
is the best linear approximation of $f(N_1,\dots,N_T)$ in the linear span of $\{ 1,N_1,\dots,N_T \}$
  with coefficients $c_t\in \R$ minimizing the mean square error 
  \begin{align*}
      E_P\biggl(   \biggl\{  f(N_1,\dots,N_T) - \biggl( c_0 + \sum_{t=1}^T c_t N_t \biggr) \biggr\}^2 \biggr) 
\end{align*}

\end{enumerate}


\item 
Let $G(\omega)$ be a standard Gaussian random variables.

For $f(x)$ differentiable with derivative satisfying $E_P(  | \partial f(G) | ) < \infty$, we define
Define the   adjoint operator $f \mapsto \partial^* f $ with
$\partial^*f(x) = x f(x)- \partial f(x)$.
\begin{enumerate}
\item 
Use the Gaussian integration by parts formula together with the product rule of calculus 
\begin{align*}
\partial(fh)=f\partial h + h\partial f
\end{align*}
to
prove the following extension  of the Gaussian integration by parts formula: 
when $E_P(f(G)^2)<\infty$ and $E_P( {\partial f(G) }^2 ) < \infty$, and
for another differantiable $h$ with 
$E_P( {\partial h(G) }^2 ) < \infty$,
\begin{align*}
  E_P(  h(G) \partial f(G) ) = E_P( f(G) \partial^* h(G) )
\end{align*}
\begin{align*}
\partial^* f(x):=x f(x)- \partial f(x)
\end{align*} 
is the adjoint of the derivative operator 
$\partial$ in the space  $L^2( \R, {\mathcal F}, \phi(x)dx)$,
where the integration measure is the standard Gaussian distribution on $\R$.


\item We 
define  the (unnormalized) Hermite  polynomials as $h_0(x)=1$, and by induction $h_n(x)= (\partial^{*n} 1)(x) = \partial^{*n} h_{n-1}(x)$.


Compute the first five $h_n(x)$ Hermite polynomials for $n=1,2,3,4,5$.

\item
Show that $E( h_n(G) ) =0$

\item
Show that $E( h_n(G), h_m(G)) = n! \delta_{nm}$ 
and in particular the random variables $h_n(G)$ and $h_m(G)$
are orthogonal  in $L^2(\Omega,{\mathcal F},P)$
Hint: use extended Gaussian integration by parts, and that $\partial^*$
is the adjoint of the derivative in $L^2( \R, {\mathcal F}, \phi(x)dx)$.
\end{enumerate}


\item
Let $f(x)$ be a function with $n$ derivatives $\partial^n f(x)$, such that $E_P( \partial^{k} f(G) ) \in L^2(\Omega,{\mathcal F},P)$
for $k=0,1,2,\dots,n$.

Show that
\begin{align*}
 \widehat f( G)= E_P( G) + \sum_{k=1}^n  \frac{ E_P(  \partial^k f(G) ) }{k!}  h_k( G ) =E_P(G)+ \sum_{k=1}^n  
 \frac{ E_P(  f(G) h_k(G) ) }{k!}  h_k( G ) 
\end{align*}
is the best polynomial approximation of $f(G)$ in the linear span of $\{ h_0(G)=1, h_1(G)=G,\dots, h_n(G) \}$
with coefficients minimizing the least square error
   \begin{align*}
      E_P\biggl(   \biggl\{  f(G) - \biggl(  \sum_{k=0}^n c_k h_n(G)  \biggr) \biggr\}^2 \biggr) 
\end{align*}
 

 Similar polynomial approximations can be computed  in the multivariate case, and also for Poisson random variables,
in that case using some  polynomials other than of Hermite polynomials, and also in
the combined case where  the linear span contains the polynomials of both Gaussian and Poisson random variables.

\item  We compute linear projections  with Bernoulli random variables. Let $X(\omega)$ be a binary random variable with
\begin{align*}
  P( X = 1 )= 1-P(X=0) = p 
\end{align*}
and $p$ in $[0,1]$.

\begin{enumerate} \item
Show that
then best linear approximation of $f(X)$ for $f:\{ 0,1\}\to \R$ in the linear span of $\{ 1, X_1(\omega)\}$ in mean square sense  is  given by 
\begin{align*}
   \widehat f(X) = %E_p( f(X) ) +    \frac{ E_p(   f(X) ( X-p) ) }{  (1-p)p }  (X(\omega) -p)
   E_p(f(X)) + ( f(1)-f(0) ) ( X -p)  
\end{align*}
where $E_P(X)=E_P(X^2)=p$.
\item 
Actually in this case the approximation is exact: check that $\widehat f(X) = f(X)$  !

\item 
For $X_1(\omega),\dots, X_T(\omega)$ independent random variables with 
\begin{align*}
  P( X_t = 1 )= 1-P(X_t=0) = p_t 
\end{align*}
and $p_t$ in $[0,1]$, and $f:\{ 0,1\}^T \to \R$, show that best linear approximation of $f(X)$ 
in the linear span of $\{ 1, X_1(\omega),\dots, X_T(\omega) \}$
in mean square sense is given{\footnotesize 
\begin{align*} &
   \widehat f(X_1,\dots,X_T)% =  E_P( f(X_1,\dots,X_n) )+ \sum_{t=1}^n  \frac{ E_P(   f(X_1,\dots,X_T) ( X_t-p_t) ) }{  (1-p_t)p_t }  (X_t(\omega) -p_t)
   = E_P( f(X) ) + & \\ & \sum_{t=1}^T E_P\bigl(  f(X_1,\dots ,X_{t-1}, 1 , X_{t+1}, \dots X_{t_n} )  - f(X_1,\dots ,X_{t-1}, 0 , X_{t+1}, \dots X_{t_n} )
   \bigr) (X_t(\omega) -p_t) &
\end{align*} }
\end{enumerate}

\end{enumerate}
\end{document}


