<div dir="ltr"><div>Hi everybody,</div><div><br></div><div>following up on this conversation of some time ago, a pre-release of the package, renamed SdePy, is now available on pip (<a href="https://pypi.org/project/sdepy">https://pypi.org/project/sdepy</a>  ) and as a project on github (<a href="https://github.com/sdepy/sdepy">https://github.com/sdepy/sdepy</a> ), version 1.0.0rc3. A short quickstart guide (<a href="https://sdepy.readthedocs.io/en/latest/intro.html#id2">https://sdepy.readthedocs.io/en/latest/intro.html#id2</a> ) is the easiest path to see what it does and what it does not. Any feedback, comments and suggestions are very welcome!</div><div><br></div><div>Since last September, the package has evolved quite a bit and had its fair share of refactoring, going through several 0.x unpublished versions before stabilizing in its current form (marked as beta). Here are a few takeaways I got from this thread, which I acted upon:</div><div><br></div><div>-  Integrating user defined SDEs turned out to be a main point of interest: this ‘odeint’ like functionality has been considerably streamlined and        simplified - formerly, preset processes were mainly in focus, and getting a new process up and running took a deep dive in a not-so-welcoming API, now upgraded as well (the former ‘integrator’ has been superseded by a ‘paths_generator’ parent class, and cooperating ‘integrator’ and ‘SDE’ classes).</div><div><br></div><div>-  The ‘kfunc’ beast was admittedly a hard sell: all undue dependencies of the core modules on its machinery have been eliminated, it plays now the role of an optional decorator for the shortcuts of frequently used stuff (it’s fully functional though and, in my experience, quite handy).</div><div><br></div><div>-  The question “Do you REALLY need a ‘process’ class” clearly stood out in your comments: after some experimentation, the main reason for answering in the yes turned out, in my view, to be its seamless interoperability with the rest of the package, hardly achievable without a dedicated design. Now process instances can indeed be fed to integrators, both as time-dependent and/or path-dependent SDE parameters, and as stochasticity sources: this opened countless hacking opportunities when doing computations, and spoiling them seemed a pity.</div><div><br></div><div>In case any of you is willing to take a look, feel free to get in touch for any problems/bugs/questions you might have</div><div><br></div><div>Cheers</div><div>Maurizio<br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, 11 Sep 2017 at 19:39, <<a href="mailto:josef.pktd@gmail.com">josef.pktd@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 11, 2017 at 12:35 PM, Maurizio Cipollina <span dir="ltr"><<a href="mailto:maurizio.cipollina@gmail.com" target="_blank">maurizio.cipollina@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Hi Ralf, </span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><br></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">thanks for going through this, here are
some follow up comments on your points:<span></span></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><span> </span></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">On the two packages you found:<span></span></span></p>

<p class="m_3027247083859270602gmail-m_6134329479955449254gmail-MsoListParagraph"></p><ul><li><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Sdeint: provides
several SDE integration algorithms but no specific processes; does not cover
processes with jumps; offers no explicit provisions for handling solutions in a
number of paths, which is what you need since the integration output is random
variables, not numbers.</span></li><li><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">SDE-higham is not a
package or tool, but rather a collection of recipes for a few textbook examples
(no jumps either), in the form that an interactive session might take (set globals,
do calculations, plot and print results).</span></li></ul><p></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><span> </span></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">About your questions/concerns:<span></span></span></p>

<p class="m_3027247083859270602gmail-m_6134329479955449254gmail-MsoListParagraph"></p><ol><li><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">ndarray subclassing: the integrator does not
depend on the process class, and process realizations may be easily tweaked to
return an ndarray instead of a process instance; however, a main point of the
package is not just to produce SDE solutions, but to allow the user to handle
them (almost) effortlessly once obtained: so one might possibly hide the
process class inside the testing suite, which depends on it, but hardly get rid
of it altogether. Indeed, I subclassed ndarray as safely as I could figure out,
but I will surely go through the scipy-dev archives and find out what advised
you against doing so.</span><br></li><li><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">odeint and scipy.integrate: my view is that odeint
churns out numbers dependant on numbers, while SDE integration churns out
random variables dependant on random variables (the stochasticity sources), so
there is a shift of paradigm and the two schemes do not fit smoothly one within
the other. The step by step integration of SDEs makes sense, and gets useful,
if you can easily control the inputs (eg. correlations among stochasticity
sources fed into different SDEs), generate the output in a decent number of
paths, and easily extract statistics of expressions dependent on it (hence the
flow ‘get a number of paths packaged as a process instance’ -> ‘do numpy algebra
with it’ -> ‘estimate probability distributions etc. using the process class
methods’ -> ‘scale it up with the montecarlo class in case the needed paths
do not fit into memory’).</span><br></li><li><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Montecarlo simulations is a big topic indeed,
that goes far beyond this package; what is called the montecarlo class is in
fact a tool to cumulate statistical information extracted from a number of
realizations of a random variable, and is focused on making easy to interpret
the output of SDE integration.</span><br></li><li><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Black-Scholes assists one more tests in a rather
extensive testing suite, and might be painlessly dropped.</span><br></li></ol><p></p>







<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><span> </span></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">This said, I see your general feeling is that
this whole subject is too specialized to fit into scipy at this stage. I suggested
otherwise, in my proposal, because stochastic calculus is regarded as one of
the pillars of modern probability theory, and covering it into scipy might be
relevant to lots of mathematicians and physicists, both practitioners and
students, that might otherwise hesitate to adopt, and build dependencies upon, a
standalone package. In case you reconsider let me know, I’d be happy to help (now
or in the future…).<span></span></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><span> </span></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">If you have further questions, let me know as
well.<span></span></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Cheers<span class="m_3027247083859270602gmail-HOEnZb"><font color="#888888"><span></span></font></span></span></p><span class="m_3027247083859270602gmail-HOEnZb"><font color="#888888">

<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Maurizio</span></p></font></span></div></div></blockquote><div><br></div><div><br></div><div>To partially follow up, similar to Ralph's view.</div><div><br></div><div>I think it would be good to have this as a separate package, or at least the code on github. </div><div>With distributions like conda it is now much easier to install additional packages, once they are established enough and are included in distributions or easily pip installable.</div><div><br></div><div>The main reason that I think scipy is currently not the appropriate package for it is that the design and review would require a lot of work. I guess that there are not many maintainers and reviewers that are familiar with this area. I also know only of applications in finance and it is not clear whether or which parts would be of more general interest.</div><div><br></div><div>In my opinion, some core tools for SDE and jump diffusions would fit in scipy. But the application support will not or might not fit well in a general purpose scientific numerical library. This would be similar to other areas where scipy provides the core computational tools, but applications are supported by other packages.</div><div><br></div><div>For example, the process class might be similar in magnitude to scipy stats distributions or signal statespace classes, but I have no idea what design for it would fit in scipy. </div><div>Some of the time aggregation properties sound similar to the corresponding pandas functions, and it is not clear whether users would want to use a separate class or just use pandas instead.</div><div><br></div><div>Similarly, the kfunc class sounds like something that doesn't have a similar pattern in scipy.</div><div><br></div><div>Design changes can be made more easily in a standalone package, while all refactorings of classes in scipy are difficult issues because of the backwards compatibility policy which requires that the design should be largely settled before a merge.</div><div><br></div><div>Josef</div><div><br></div><div><a href="https://groups.google.com/d/msg/pystatsmodels/xsttiEiyqAg/maR6n4EeAgAJ" target="_blank">https://groups.google.com/d/msg/pystatsmodels/xsttiEiyqAg/maR6n4EeAgAJ</a><br></div><div>(stackoverflow question has been deleted "Is there a library out there to calibrate an Ornstein-Uhlenbeck model?")</div><div><br></div><div><a href="https://github.com/statsmodels/statsmodels/blob/master/statsmodels/sandbox/tsa/diffusion.py" target="_blank">https://github.com/statsmodels/statsmodels/blob/master/statsmodels/sandbox/tsa/diffusion.py</a> and diffusion2.py<br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span class="m_3027247083859270602gmail-HOEnZb"><font color="#888888"><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><span></span></span></p></font></span></div><div><div class="m_3027247083859270602gmail-h5"><div><br></div><br><div class="gmail_extra"><br><div class="gmail_quote">On 9 September 2017 at 03:31, Ralf Gommers <span dir="ltr"><<a href="mailto:ralf.gommers@gmail.com" target="_blank">ralf.gommers@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Maurizio,<br><br><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 8, 2017 at 7:55 PM, Maurizio Cipollina <span dir="ltr"><<a href="mailto:maurizio.cipollina@gmail.com" target="_blank">maurizio.cipollina@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px">Hi everybody, and first of all thanks for the great job you have been doing, on which I relied *A LOT* over time.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">Stochastic calculus and Stochastic Differential Equations are a significant branch of mathematics that to my understanding is underrepresented in scipy, as well as in the open source python stack at large. I may well be missing something, but as I can see one can find out there many recipies or collections of recipies, and a number of packages/projects skewed towards finance, but no structured framework for generating and handling stochastic processes and numerically solving SDEs.</span><br style="font-size:12.8px"></font></div></blockquote><div><br></div><div>I've never used these, but a quick search turns up two packages:<br></div><div>  <a href="https://pypi.python.org/pypi/sdeint" target="_blank">https://pypi.python.org/pypi/sdeint</a></div><div>  <a href="https://github.com/alu042/SDE-higham" target="_blank">https://github.com/alu042/SDE-higham</a><br></div><div>Not very mature probably, but would be good to compare your code with those.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px">This is a pity, since scipy/numpy provide efficen implementations of all the basic ingredients needed to do the trick. Out of professional need, and prompted by this gap, I have developed a general purpose package of which I own the copyright, and which I would be happy to release under the BSD license as part of scipy, in case there is a consensus among the scipy community that it makes sense to do so (the package has no dependencies beyond standard library, numpy and scipy, and might probably fit best as a subpackage of scipy.stats).</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">Before setting up a PR, I would be happy to hear your thoughts: I have pasted below the package docstring, that should give an overview of its scope and limitations. Please note that some of the realized processes stray into mathematical finance territory, somehow inevitably since finance is one major field of application of stochastic calculus, but the focus is the latter, not the former, at least in my intentions.</span><br style="font-size:12.8px"></font></div></blockquote><div><br></div><div>First thought: this looks like a useful addition to the scientific Python ecosystem, but is probably too specialized for SciPy (at least at this stage).</div><div><br></div><div>Based on your docstring below, here are some questions/concerns:</div><div>1. We definitely don't want a new ndarray subclass (there's a pretty strong consensus at this point that subclassing ndarray is usually not a good solution), so your `process` doesn't sound attractive.</div><div>2. The `integrator` class sounds a lot like odeint, so maybe this would fit better with scipy.integrate?</div><div>3. Monte-Carlo simulation is a big and fairly technical topic. There are whole packages (e.g. PyMC3, emcee) dedicated to this. It may not fit well with SciPy.</div><div>4. Things specific to finance like Black-Scholes and put/call options are not a good fit.</div><div>5. Maintainers for this added code. The ODE integrators in scipy.integrate already suffer from lack of a dedicated maintainer, SDEs are more specialized so are likely to not be very well-maintained by other devs than you.</div><div><br></div><div>Without seeing your code it's hard to say for sure, but it looks to me like it would be better to release your code as a standalone package.</div><div><br></div><div>Cheers,</div><div>Ralf<br></div><div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><font face="arial, helvetica, sans-serif"><br style="font-size:12.8px"><span style="font-size:12.8px">Thanks in advance for taking your time to go through this, and for your comments and suggestions.</span><br style="font-size:12.8px"><span style="font-size:12.8px">Maurizio</span><br style="font-size:12.8px"></font><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">“””</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">==============================</span><span style="font-family:monospace,monospace;font-size:12.8px">=============================</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">Stochastic - Monte Carlo simulation of stochastic processes</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">==============================</span><span style="font-family:monospace,monospace;font-size:12.8px">=============================</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">This package provides:</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">1.  A `process` class, a subclass of `numpy.ndarray` representing</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    a sequence of values in time, realized in one or several paths.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    Algebraic manipulations and ufunc computations are supported for</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    instances that share the same timeline and comply with numpy</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    broadcasting rules. Interpolation along the timeline is supported</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    via callability of `process` instances. Process-specific functionalities,</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    such as averaging and indexing along time or across paths, are delegated</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    to process-specific methods, attributes and properties (no overriding</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    of `numpy.ndarray` operations).</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">2.  The `source` class and its subclasses, stochasticity sources providing</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    numerical realizations of the differentials commonly found</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    in stochastic differential equations (SDEs), with or without</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    memory of formerly invoked realizations.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">3.  The `integrator` class, a general framework for numerical SDE</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    integration, intended for subclassing, to assist the definition of step by</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    step integration algorithms and the computation of numerical realizations of</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    stochastic processes.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">4.  Several objects providing realizations of specific stochastic processes</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    along a given timeline and across a requested number of paths.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    Realizations are obtained via explicit formulae, in case the relevant SDE</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    has a closed form solution, or otherwise as `integrator` subclasses performing</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    Euler-Maruyama numerical integration.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">5.  A `montecarlo` class, as an aid to cumulate the results of several</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    Monte Carlo simulations of a given stochastic variable, and to extract</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    summary estimates for its probability distribution function and</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    statistics, thus supporting simulations across a number of paths that exceeds</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    the maximum allowed by available memory.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">6.  Several analytical results relating to the supported stochastic</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">    processes, as a general reference and for testing purpouses.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">For all sources and realizations, process values can take any shape,</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">scalar or multidimensional. Correlated multivariate stochasticity sources are</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">supported. Time-varying process parameters (correlations, intensity of Poisson</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">processes, volatilities etc.) are allowed whenever applicable.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">`process` instances act as valid stochasticity source realizations (as does</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">any callable object complying with a `source` protocol), and may be</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">passed as a source specification when computing the realization of a given</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">process.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">Computations are fully vectorized across paths, providing an efficient</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">infrastructure for simulating a large number of process realizations.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">Less so, for large number of time steps: integrating 1000 time steps</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">across 100000 paths takes seconds, one million time steps across</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">100 paths takes minutes.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">General infrastructure</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">======================</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">.. autosummary::</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   :toctree: generated/</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   process     -- Array representation of a process (a subclass of</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                  -- numpy.ndarray).</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   kfunc       -- Base class for functions with managed keyword arguments.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   source      -- Base class for stochasticity sources.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   true_source -- Base class for stochasticity sources with memory.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   integrator  -- General framework for numerical SDE integration.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   montecarlo  -- Summmary statistics of Monte Carlo simulations.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">Stochasticity sources</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">=====================</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">.. autosummary::</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   :toctree: generated/</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   wiener              -- dW, a source of standard Wiener process (Brownian</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                          -- motion) increments.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   symmetric_wiener    -- as above, with symmetric paths (averages exactly 0).</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   true_wiener         -- dW, a source of standard Wiener process (Brownian</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                          -- motion) increments, with memory.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   poisson             -- dN, a source of Poisson process increments.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   compound_poisson    -- dJ, a source of compound Poisson process increments.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                          -- (jumps distributed in time as a Poisson process,</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                          -- and in size as a given `scipy.stats` distribution).</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   compound_poisson_rv -- Preset jump size distributions for compound Poisson</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                          -- process increments.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">Stochastic process realizations</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">==============================</span><span style="font-family:monospace,monospace;font-size:12.8px">=</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">.. autosummary::</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   :toctree: generated/</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   const_wiener_process          -- Wiener process (Brownian motion), with</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- time-independent parameters.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   const_lognorm_process         -- Lognormal process, with time-independent</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- parameters.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   wiener_process                -- Wiener process (Brownian motion).</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   lognorm_process               -- Lognormal process.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   ornstein_uhlenbeck_process    -- Ornstein-Uhlenbeck process (mean-reverting</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- Brownian motion).</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   hull_white_process            -- F-factors Hull-White process (sum of F</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- correlated mean-reverting Brownian</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- motions).</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   hull_white_1factor_process    -- 1-factor Hull-White process (F=1 Hull-White</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- process with F-index collapsed to a</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- scalar).</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   cox_ingersoll_ross_process    -- Cox-Ingersoll-Ross mean-reverting process.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   full_heston_process           -- Heston stochastic volatility process</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- (returns both process and volatility).</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   heston_process                -- Heston stochastic volatility process</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- (stores and returns process only).</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   jump_diffusion_process        -- Jump-diffusion process (lognormal process</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- with compound Poisson jumps).</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   merton_jump_diffusion_process -- Merton jump-diffusion process</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- (jump-diffusion process with normal</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- jump size distribution).</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   kou_jump_diffusion_process    -- Kou jump-diffusion process (jump-diffusion</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- process with double exponential</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">                                    -- jump size distribution).</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">Shortcuts::</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   lognorm -- lognorm_process</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   oruh    -- ornstein_uhlenbeck_process</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   hwp     -- hull_white_process</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   hw1f    -- hull_white_1factor_process</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   cir     -- cox_ingersoll_ross_process</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   heston  -- heston_process</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   mjd     -- merton_jump_diffusion_process</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   kou     -- kou_jump_diffusion_process</span><br style="font-size:12.8px"><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">Analytical results</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">==================</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">Exact statistics for the realized stochastic processes</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">are listed below, limited to the case of constant process parameters and with</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">some further limitations to the parameters' domains.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">Function arguments are consistent with those of the corresponding processes.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">Suffixes `pdf`, `cdf` and `chf` stand respectively for probability distribution</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">function, cumulative probability distribution function, and characteristic</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">function. Black-Scholes formulae for the valuation of call and put options have been</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">included (prefixed with `bs` below).</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">.. autosummary::</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   :toctree: generated/</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   wiener_mean</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   wiener_var</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   wiener_std</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   wiener_pdf</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   wiener_cdf</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   wiener_chf</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   lognorm_mean</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   lognorm_var</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   lognorm_std</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   lognorm_pdf</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   lognorm_cdf</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   lognorm_log_chf</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   oruh_mean</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   oruh_var</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   oruh_std</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   oruh_pdf</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   oruh_cdf</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   hw2f_mean</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   hw2f_var</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   hw2f_std</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   hw2f_pdf</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   hw2f_cdf</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   cir_mean</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   cir_var</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   cir_std</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   cir_pdf</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   heston_log_mean</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   heston_log_var</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   heston_log_std</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   heston_log_pdf</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   heston_log_chf</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   mjd_log_pdf</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   mjd_log_chf</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   kou_mean</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   kou_log_pdf</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   kou_log_chf</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   bsd1d2</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   bscall</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   bscall_delta</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   bsput</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">   bsput_delta</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">Notes</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">=====</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">To the benefit of interactive and notebook sessions, and as an aid to fluently</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">freeze or vary the plurality of parameters that define each stochastic process,</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">all sources, process realizations and analytical results are objects</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">with managed keywords (subclasses of `kfunc`): if the corresponding classes</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">are instantiated with both variables (non keyword arguments) and parameters</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">(keyword arguments), they behave as functions returning the computations'</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">result; if called with parameters only, return an instance that stores the set</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">parameters, and exposes the same calling pattern (call with variables</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">and optionally with parameters to get results, call with parameters only</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">to get a new instance storing modified parameters).</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">Parameters that are not specified fall back to the class defaults, if calling</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">the class, or to the instance's stored values, if calling an instance.</span><br style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">"""</span><br></div>
<br>_______________________________________________<br>
SciPy-Dev mailing list<br>
<a href="mailto:SciPy-Dev@python.org" target="_blank">SciPy-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scipy-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scipy-dev</a><br>
<br></blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
SciPy-Dev mailing list<br>
<a href="mailto:SciPy-Dev@python.org" target="_blank">SciPy-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scipy-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scipy-dev</a><br>
<br></blockquote></div><br></div></div></div></div>
<br>_______________________________________________<br>
SciPy-Dev mailing list<br>
<a href="mailto:SciPy-Dev@python.org" target="_blank">SciPy-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scipy-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scipy-dev</a><br>
<br></blockquote></div><br></div></div>
_______________________________________________<br>
SciPy-Dev mailing list<br>
<a href="mailto:SciPy-Dev@python.org" target="_blank">SciPy-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scipy-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scipy-dev</a><br>
</blockquote></div></div>