Necessary and sufficient condition for random sum of independent RVs to be a martingale

Let $$M$$ be a Poisson random measure on $$(0,\infty)$$ with intensity $$\lambda dt$$, where $$\lambda\in(0,\infty)$$. Let $$(Y_n)_{n\in\mathbb{N}}$$ be a sequence of independent random variables, independent of $$M$$ and distributed uniformly on $$[0,1]$$. Given a measurable function $$g$$ on $$[0,1]$$, define $$X_t=X_t^g=\sum_{n=1}^{N_t}g(Y_n)$$ where $$N_t=M(0,t]$$.

I have shown, using partitioning of the expectation and Fubini, that in the case $$g\geq0$$ we have $$\mathbb{E}(X_t)=\lambda t\int_0^1g(y)dy.$$ I am now tasked to find a necessary and sufficient condition on $$g$$ for $$(X_t)_{t\geq0}$$ to be a martingale.

My thinking was that, according to the OST, a necessary and sufficient condition is $$\mathbb{E}(X_T)=\mathbb{E}(X_0)=0$$ for all bounded stopping times $$T$$. Suppose that $$g\geq0$$. Then from the formula above, we see that for any $$t>0$$, we require that $$g\equiv0$$ on $$[0,1]$$ otherwise $$\mathbb{E}(X_t)>0$$. So I feel that it will be necessary for $$g$$ to be non-positive. I do not know how to proceed from here though, so would greatly appreciate advice.

• Martingale with respect to what filtration more exactly? Only the natural filtration of the Poisson process or compounding with the $\sigma$-algebra $\sigma(Y_n: n\in \mathbb{N})$ as well? Commented May 9, 2022 at 9:44
• In the latter case, a necessary and sufficient condition, if I am not missing anything is $\mathbb{E}\left[g(Y)\right]=0$. Commented May 9, 2022 at 9:59
• My answer was not correct and I deleted it. Thank you. Commented May 9, 2022 at 11:00
• For my comment regarding Fubini - I actually am not sure if it is necessary as the expectation is a linear operator and so for a finite sum we should be able to interchange the sum and expectation anyway. However I am now confused as the question (question 6 on maths.cam.ac.uk/postgrad/part-iii/files/pastpapers/2019/…) specifies the case that $g\geq0$ for part b, but now I am unsure why that is necessary. Commented May 9, 2022 at 11:06
• Indeed, I think this corrects the solution I posted. Let me check. Commented May 9, 2022 at 11:28

Let $$\mathcal{F}_t$$ be the natural filtration of the process $$\left(X_t\right)_{t\geq 0}$$.

Claim. $$\left(X_t\right)_{t\geq 0}$$ is a martingale w.r.t. $$\mathcal{F}_t$$ if and only if $$\mathbb{E}\left[g(Y)\right]=0$$.

Proof. For any $$s, we have $$\mathbb{E}\left[X_t\left|\mathcal{F}_s\right.\right]=\mathbb{E}\left[\sum\limits_{n=1}^{N_t}g(Y_n)\left|\mathcal{F}_s\right.\right]=\mathbb{E}\left[\sum\limits_{n=1}^{N_s}g(Y_n)\left|\mathcal{F}_s\right.\right]+\mathbb{E}\left[\sum\limits_{n>N_s}^{N_s+M\left.\left[s,t\right.\right)}g(Y_n)\left|\mathcal{F}_s\right.\right]=X_s+\mathbb{E}\left[\sum\limits_{n>N_s}^{N_s+M\left.\left[s,t\right.\right)}g(Y_n)\right]$$,

and

$$\mathbb{E}\left[\sum\limits_{n>N_s}^{N_s+M\left.\left[s,t\right.\right)}g(Y_n)\right]=\mathbb{E}\left[\sum\limits_{n=1}^{N_{t-s}}g(Y_n)\right]=\mathbb{E}\left[\sum\limits_{n=1}^{N_{t-s}}g(Y_{n+N_{t-s}})\right]=\mathbb{E}\left[\mathbb{E}\left[\sum\limits_{n=1}^{N_{t-s}}g(Y_{n+N_{t-s}})\left|\mathcal{F}_{t-s}\right.\right]\right]=\mathbb{E}\left[\sum\limits_{n=1}^{N_{t-s}}\mathbb{E}\left[g(Y_{n+N_{t-s}})\left|\mathcal{F}_{t-s}\right.\right]\right]=\mathbb{E}\left[\sum\limits_{n=1}^{N_{t-s}}\mathbb{E}\left[g(Y)\right]\right]=\lambda(t-s)\mathbb{E}\left[g(Y)\right]$$,

which is zero if and only if $$\mathbb{E}\left[g(Y)\right]=0$$.

If $$g\geq 0$$ then, $$\mathbb{E}\left[g(Y)\right]=0\Rightarrow g=0$$ almost everywhere in $$\left[0,1\right]$$.