# Geometric Brownian Motion with two-state diffusion/volatility

let's assume a GBM process S(t) with dynamics:

dS(t) = a S(t) dt + b S(t) dB(t)

where B(t) is a Brownian motion, a and b are constants, and S(0)>0.

For any time s>t, we have that

E_t[S(s)^k] = S(t)^k exp(q(s-t))

for any k such that the expectation exists and where E_t[] is the expectation operator conditional on the process S(t) up to time t and q() is a deterministic function of time.

Now my question concerns how to compute the same kind of expectation when the diffusion coefficient b is not a constant but follow a two-state Markov process whose dynamics can be defined by a transition probability matrix or a sde.

I understand how to compute the transition probability matrix between time t and time s, but it is not clear to me how to compute the full expectation.

I would also like to understand the methodology when the underlying process is a more general (exponential) affine process than a GBM (that is, when in absence of state switching, the above expectation has exponential affine form).

Thanks really a lot in advance.