-
Notifications
You must be signed in to change notification settings - Fork 58
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
Milstein function #615
base: develop
Are you sure you want to change the base?
Milstein function #615
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #615 +/- ##
===========================================
+ Coverage 86.65% 86.90% +0.24%
===========================================
Files 156 158 +2
Lines 13322 13568 +246
===========================================
+ Hits 11544 11791 +247
+ Misses 1778 1777 -1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried to do a quick review, so that you can incorporate the feedback before your presentation, but I did not review the math nor the code/tests correctness.
and Postintervention in Structural Equation Models. PhD thesis, USA, | ||
2020. AAI29605510 | ||
""" | ||
random_state = validate_random_state(random_state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have the bandwidth now to check for code correctness in depth. I will assume that Alberto has reviewed the code and tests with you thoroughly. If that is not true, please let me now to recheck it later before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, I apologize for taking so long on reviewing this PR. I had a lot of work to do and very few time to dedicate to this.
I hope I will have more time now, so if you are busy and/or do not want to make the changes to merge this PR, just tell me and I will try to make them on my own and merge it.
# Using Milstein's method to compute SDE solutions | ||
# --------------------------------------------------- | ||
# | ||
# Apart from func:`~skfda.datasets.make_sde_trajectories`, scikit-fda also |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Apart from func:`~skfda.datasets.make_sde_trajectories`, scikit-fda also | |
# Apart from :func:`~skfda.datasets.make_sde_trajectories`, scikit-fda also |
Also, now they are in the same function.
# does not depend on the value of :math:`\mathbf{X}`, then both methods | ||
# Euler Maruyama and Milstein are equivalent. In this section we show how | ||
# to use the former function for SDEs where the diffusion term does depend | ||
# :math:`X`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# :math:`X`. | |
# on :math:`X`. |
stop: float = 1.0, | ||
diffusion_matricial_term: bool = True, | ||
random_state: RandomStateLike = None, | ||
) -> FDataGrid: | ||
r"""Numerical integration of an Itô SDE using the Euler-Maruyana scheme. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r"""Numerical integration of an Itô SDE using the Euler-Maruyana scheme. | |
r"""Numerical integration of an Itô SDE. |
(Not true anymore)
density=True, | ||
label="Empirical pdf", | ||
) | ||
ax[1].plot( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be cool to paint this vertically on the right, to match what happens in the other plot. Not mandatory, though.
np.exp(grid_points * mu), | ||
linewidth=2, | ||
label="theoretical mean", | ||
color='b', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you use single quotes sometimes? I think it is better to stick with double quotes.
raise ValueError( | ||
"Invalid initial conditions. Each of the starting points " | ||
"must be a flat array.", | ||
raise ValueError("Method for computing SDEs not implemented") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include the method name for a better debugging experience.
times: NDArrayFloat, | ||
random_state: np.random.RandomState, | ||
) -> FDataGrid: | ||
r"""Numerical integration of an Itô SDE using the Euler-Maruyana scheme. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r"""Numerical integration of an Itô SDE using the Euler-Maruyana scheme. | |
r"""Numerical integration of an Itô SDE using the Milstein scheme. |
References to issues or other PRs
Describe the proposed changes
Added milstein function which computes the Milstein scheme for Stochastic Differential Equations (SDEs). Additionally, examples which show the functionality of the SDE solvers are added.
Additional information
Checklist before requesting a review