statsmodels / statsmodels/statsmodels
ENH: complex step derivative
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.6k
- Forks
- 3.6k
- Avg merge
- 7h 37m
- Merged PRs (30d)
- 96
Description
It's very accurate for first derivatives but doesn't work for all functions.
eg. scipy.stats.norm.cdf doesn't work, but erf does
we can fix Probit and similar models for this (although we know the derivative of the cdf already)
>>> (0.5+0.5*special.erf((1+ 1e-8 * 1j)/np.sqrt(2))).imag / 1e-8 - stats.norm.pdf(1)
8.3266726846886741e-17
collection of function extended to complex so they work with complex step derivatives
see fortran version here
http://mdolab.engin.umich.edu/content/guide-complex-step-derivative-approximation-0
found in here http://blogs.mathworks.com/cleve/2013/10/14/complex-step-differentiation/
with more references
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the complex-step example comparing scipy.stats.norm.cdf with special.erf, then inspect the Probit and related model entry points. Done means the relevant functions accept complex inputs and complex-step derivatives agree with the expected derivative values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100