Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brownian bridge and quasi-MC #10

Open
sdementen opened this issue Oct 5, 2023 · 6 comments
Open

brownian bridge and quasi-MC #10

sdementen opened this issue Oct 5, 2023 · 6 comments

Comments

@sdementen
Copy link

first things first, great package, tx! I have just tried some examples but look very promising.

what is the control one can have on the generation of random numbers while generating tracjectories ?
I would like to be able to use a quasi-MC (sobol) RNG combined with some brownian bridge transformation. Is there a hook I can use to provide a function that generates the random numbers ?

@RadostW
Copy link
Owner

RadostW commented Oct 5, 2023

Thanks! 😊

First of all, you can already get Brownian bridge samples with the current backend. It's not immediately obvious but Brownian bridge is actually an Ito process itself

(cf https://math.stackexchange.com/questions/1369834/brownian-bridge-sde )

If you want to drive your process with Brownian bridge then with some algebra you can express your SDE against dB as an SDE against dW (with B bridge and W wiener processes respectively).

Take a look at the code below:

import pychastic
import jax.numpy as jnp

a = 1
b = -1
tmax = 1

problem = pychastic.sde_problem.SDEProblem(
    lambda x: jnp.array([1, (b - x[1]) / (1 - x[0])]),
    lambda x: jnp.array([[0], [1]]),
    x0=jnp.array([0, a]),
    tmax=tmax,
)
solver = pychastic.sde_solver.SDESolver(dt=0.001)
trajectory = solver.solve_many(problem,n_trajectories = 10)

import matplotlib.pyplot as plt

for t in trajectory["solution_values"]:
    plt.plot(trajectory["time_values"][0,:], t[:,1])
plt.show()

If you really need to control the RNG then it's controlled by
get_wiener_integrals function from:
"https://github.com/RadostW/stochastic/blob/main/pychastic/vectorized_I_generation.py"
To support higher order schemes this function is rather complex because we need approximations of multiple integrals.

I'm not familiar with "quasi-MC (sobol)" what does that mean? Could you provide more detail on the problem you're trying to solve?

@sdementen
Copy link
Author

sdementen commented Oct 5, 2023 via email

@RadostW
Copy link
Owner

RadostW commented Oct 5, 2023

I think attachments don't work properly inside GitHub threads.

The Sobol sequence idea sounds very interesting - it seems scipy has the initialization numbers done correctly up to dimension 21201. I haven't looked very deep but it seems that we could just draw uniformly on a hypercube and then transform with normal CDF.

Perhaps an integration scheme "sobol-euler" could be implemented relatively easily and exposed to the users similarly to other solvers?

Inside the package there are already some correctness tests so debugging should go smoothly.

@sdementen
Copy link
Author

sdementen commented Oct 5, 2023 via email

@sdementen
Copy link
Author

sdementen commented Oct 5, 2023 via email

@sdementen
Copy link
Author

I have python code that builds up the matrix L in QMC.pdf p 25, 26 and 29 to use classic MC, PCA or BB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants