# Modifying OrnsteinUhlenbeckBridge in DifferentialEquations.jl

**URL:** <https://discourse.julialang.org/t/modifying-ornsteinuhlenbeckbridge-in-differentialequations-jl/116168>\
**Category:** Modelling & Simulations\
**Tags:** sde, sciml\
**Created:** [June 25, 2024, 1:42am UTC](https://discourse.julialang.org/t/modifying-ornsteinuhlenbeckbridge-in-differentialequations-jl/116168 "2024-06-25T01:42:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dleather](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dleather/32/43762_2.png) [@dleather](https://discourse.julialang.org/u/dleather)\
**Post date:** [June 25, 2024, 1:42am UTC](https://discourse.julialang.org/t/modifying-ornsteinuhlenbeckbridge-in-differentialequations-jl/116168/1 "2024-06-25T01:42:02Z")

</div>

Suppose X(t) is an Ornstein-Uhlenbeck (OU) process, and Y(t; t\_0, T, u, v) is the respective OU bridge process such that Y(t\_0) = u, Y(T) = v, and 0 \lt t \lt T.

I’ve had great use of simulating Y(t) using `DiffEqNoiseProcess.OrnsteinUhlenbeckBridge()`, kudos to those responsible. But now I need to simulate integrals of \int\_{t\_0}^T e^{\kappa (t - t\_0)} Y(t)dt, and was wondering if it is feasible to create a new bridge with the additional exponential smoothing term?

Brief background: the integrals are the result of the solution to the following system:  
\begin{align} dX(t) & = - \theta X(t) dt + \sigma\_x dW\_x(t)\end{align}\\ dZ(t) = \kappa (\mu - Z(t))dt + \xi\_1 X(t) dt + \xi\_2 X^2(t) dt + \sigma\_z dW\_z(t).

Edit: Maybe this is as simple as post-multiplying the simulated paths of Y(t) by e^{\kappa (t - t\_0)}, and changing the starting and terminal values, but I am not certain that would be valid.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 26, 2024, 5:01am UTC](https://discourse.julialang.org/t/modifying-ornsteinuhlenbeckbridge-in-differentialequations-jl/116168/2 "2024-06-26T05:01:57Z")

</div>

> [@dleather](#):
>
> dX(t)=−θX(t)dt+σxdWx(t)dZ(t)=κ(μ−Z(t))dt+ξ1X(t)dt+ξ2X2(t)dt+σzdWz(t)

Just put that into the SDE solver?

---

<div class="post-metadata">

**Author:** ![dleather](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dleather/32/43762_2.png) [@dleather](https://discourse.julialang.org/u/dleather)\
**Post date:** [June 29, 2024, 5:18am UTC](https://discourse.julialang.org/t/modifying-ornsteinuhlenbeckbridge-in-differentialequations-jl/116168/4 "2024-06-29T05:18:53Z")

</div>

Sure, but how can I tell the solver that I want to condition X(t) on a start- and end-value, so it is represented as a OU bridge, Y(t), _as well as_ simulate the dynamics of the joint-process [Y(t), Z(t)]^\prime. I’ve looked through the docs and I’m not sure it’s supported, but I’m wondering if maybe there is a clever way.

My end-goal is to test my closed-form solution to the mean of Z(t), conditional on the OU bridge.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 29, 2024, 7:42am UTC](https://discourse.julialang.org/t/modifying-ornsteinuhlenbeckbridge-in-differentialequations-jl/116168/5 "2024-06-29T07:42:00Z")

</div>

It’s just appending a few more SDEs onto those? I’m not entirely sure what the question is.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 29, 2024, 7:43am UTC](https://discourse.julialang.org/t/modifying-ornsteinuhlenbeckbridge-in-differentialequations-jl/116168/6 "2024-06-29T07:43:37Z")

</div>

Wait, you want to condition based on properties of the noise? If you want to do that then you may need to use forward backward filtering, MitosisStochasticDiffEq.jl might have the right tool for this

---

<div class="post-metadata">

**Author:** ![dleather](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dleather/32/43762_2.png) [@dleather](https://discourse.julialang.org/u/dleather)\
**Post date:** [June 29, 2024, 8:00am UTC](https://discourse.julialang.org/t/modifying-ornsteinuhlenbeckbridge-in-differentialequations-jl/116168/7 "2024-06-29T08:00:53Z")

</div>

> [@ChrisRackauckas](#):
>
> d on properties of the noise? If you want to do that then you may need to use forward backward filtering, [MitosisStochasticDiffEq.jl](https://juliahub.com/ui/Packages/General/MitosisStochasticDiffEq) might have the right tool for this

Thanks, I’m indeed interested in using their BFFG algorithm later in my work.

I was able to take advantage of the fact that an OU bridge have the following general-linear SDE representation from [Barczy & Kern (2013)](https://arxiv.org/pdf/1011.0067)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/b/2b2099ab148f6378cc1fbebbd6a032dfc0da1357.png).  
and solve the problem by defining a custom drift function.

Then general idea I wanted to accomplish however was

```julia
w_noise = WienerProcess(...)
oub_noise= DiffEqNoiseProcess.OrnsteinUhlenbeckBridge(...)
W = [w_noise, oub_noise]
prob = SDEProblem(drift!, diffusion!, u0, (0.0, Δt), noise = W)

```

where the drift function would output a vector for a diagonal noise process.

Seems like it may be possible by defining a custom `NoiseProcess` but I came across the reference while trying to understand the custom constructor.

Apologies for the lack of clarity in my previous posts.
