You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm interested in PRing some stochastics not checked off in the README. The Ho-Lee and Hull-White model have time-varying mean reversion and volatility parameters, respectively.
I've currently implemented the time-varying parameters as struct fields of the form fn(f64) -> f64. This way, the user can define a function with input t: f64 and the euler_murayama discretization will compute the needed value drift or diffusion at time t.
Is this a good choice? One difficulty of this is introducing comprehensive unit tests, where closed-form solutions to the SDEs might not be analytically solvable apart from some very simple cases.
EDIT: It looks like my understanding of the discretization wasn't correct. The funcion passes the value of process at the previous time step into the .drift() and .diffusion() functions, not the time itself. A different choice of how to implement time-varying parameters must be made.
Using function fields to represent time-varying parameters in your struct is a valid approach. It allows flexibility for users to define their own functions and compute the required values at each time step.
However, as you mentioned, it can make comprehensive unit testing challenging, especially when closed-form solutions are not analytically solvable. In such cases, you may need to rely on numerical methods or approximation techniques to validate your implementation.
Regarding the correction you mentioned, if the functions .drift() and .diffusion() require the value of the process at the previous time step rather than the time itself, you will need to revise your implementation accordingly. One possible approach is to store the previous process value as a field in your struct and update it at each time step.
Remember to carefully consider the trade-offs between flexibility, complexity, and testability when making design choices for your implementation.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm interested in PRing some stochastics not checked off in the README. The Ho-Lee and Hull-White model have time-varying mean reversion and volatility parameters, respectively.
I've currently implemented the time-varying parameters as struct fields of the form
fn(f64) -> f64
. This way, the user can define a function with inputt: f64
and theeuler_murayama
discretization will compute the needed valuedrift
ordiffusion
at timet
.Is this a good choice? One difficulty of this is introducing comprehensive unit tests, where closed-form solutions to the SDEs might not be analytically solvable apart from some very simple cases.
EDIT: It looks like my understanding of the discretization wasn't correct. The funcion passes the value of process at the previous time step into the
.drift()
and.diffusion()
functions, not the time itself. A different choice of how to implement time-varying parameters must be made.Beta Was this translation helpful? Give feedback.
All reactions