<p dir="auto"><strong>Is your feature request related to a problem? Please describe.</strong></p>
<p dir="auto">The feature is related to a problem where I am unclear as to how to translate my data into parameters: <code class="notranslate">n</code> and <code class="notranslate">p</code> for <code class="notranslate">nbinom.cdf</code>. I am sort of lost translating R to Python here given different params:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="test_arr = np.array([(1, 1, 3, 1, 1, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 0, 3, 2, 1, 5, 2, 2,
           4, 0, 7, 3, 0, 0, 2, 1, 2, 0, 1, 4, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1,
           0, 0, 0, 0, 0, 2, 0, 3, 3, 1, 3, 0, 0, 2, 0, 3, 1, 0, 0, 0, 0, 1,
           0, 4, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 2, 1, 2, 0, 0, 3, 2, 2, 0, 3,
           0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 1, 0)])
nbinom.cdf(test_arr, n=?, p=?)  # how determine n and p from the data?"><pre class="notranslate"><code class="notranslate">test_arr = np.array([(1, 1, 3, 1, 1, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 0, 3, 2, 1, 5, 2, 2,
           4, 0, 7, 3, 0, 0, 2, 1, 2, 0, 1, 4, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1,
           0, 0, 0, 0, 0, 2, 0, 3, 3, 1, 3, 0, 0, 2, 0, 3, 1, 0, 0, 0, 0, 1,
           0, 4, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 2, 1, 2, 0, 0, 3, 2, 2, 0, 3,
           0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 1, 0)])
nbinom.cdf(test_arr, n=?, p=?)  # how determine n and p from the data?
</code></pre></div>
<p dir="auto"><strong>Describe the solution you'd like</strong></p>
<p dir="auto">When using R, I can obtain <code class="notranslate">nbinom.cdf</code> seemingly from the data itself</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="library(pscl)
arr1 &lt;- c(1, 1, 3, 1, 1, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 0, 3, 2, 1, 5, 2, 2,
           4, 0, 7, 3, 0, 0, 2, 1, 2, 0, 1, 4, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1,
           0, 0, 0, 0, 0, 2, 0, 3, 3, 1, 3, 0, 0, 2, 0, 3, 1, 0, 0, 0, 0, 1,
           0, 4, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 2, 1, 2, 0, 0, 3, 2, 2, 0, 3,
           0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 1, 0)
m1 &lt;- zeroinfl(arr1 ~ 1, dist='negbin')
m1$theta  # dispersion param

library(VGAM)
# size is dispersion parameter
pnbinom(arr1, size=m1$theta, mu=mean(arr1))"><pre class="notranslate"><code class="notranslate">library(pscl)
arr1 &lt;- c(1, 1, 3, 1, 1, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 0, 3, 2, 1, 5, 2, 2,
           4, 0, 7, 3, 0, 0, 2, 1, 2, 0, 1, 4, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1,
           0, 0, 0, 0, 0, 2, 0, 3, 3, 1, 3, 0, 0, 2, 0, 3, 1, 0, 0, 0, 0, 1,
           0, 4, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 2, 1, 2, 0, 0, 3, 2, 2, 0, 3,
           0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 1, 0)
m1 &lt;- zeroinfl(arr1 ~ 1, dist='negbin')
m1$theta  # dispersion param

library(VGAM)
# size is dispersion parameter
pnbinom(arr1, size=m1$theta, mu=mean(arr1))
</code></pre></div>
<p dir="auto">It would be nice to derive the CDF of a value/vector by specifying the dispersion parameter and the mean.</p>
<p dir="auto"><strong>Describe alternatives you've considered</strong><br>
N/A</p>
<p dir="auto"><strong>Additional context (e.g. screenshots)</strong><br>
N/A</p>
<h3 dir="auto">Describe your issue.</h3>
<p dir="auto">In the following example with CubicSpline y=cos(x), I would naively expect a single root x=1 for cos(x)=1. However, it returns three nearly identical roots instead.<br>
In another rare case where the curve is monotonic (I will provide the example when I get access to my data later), I also get two close roots, which only differ by 1e-16.</p>
<p dir="auto">Is this expected or not? If yes, any good idea to search and remove such redundancy roots? Thanks.</p>
<h3 dir="auto">Reproducing Code Example</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
from scipy.interpolate import CubicSpline

x = np.linspace(-1, 1, 101)
y = cos(x)
f = CubicSpline(x, y)
rt = f.solve(1, extrapolate=False)
# array([-1.79965237e-07,  0.00000000e+00,  1.56105529e-16])
f(rt) - 1
# array([-1.62092562e-14,  0.00000000e+00,  0.00000000e+00])"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">from</span> <span class="pl-s1">scipy</span>.<span class="pl-s1">interpolate</span> <span class="pl-k">import</span> <span class="pl-v">CubicSpline</span>

<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">-</span><span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">101</span>)
<span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-en">cos</span>(<span class="pl-s1">x</span>)
<span class="pl-s1">f</span> <span class="pl-c1">=</span> <span class="pl-v">CubicSpline</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>)
<span class="pl-s1">rt</span> <span class="pl-c1">=</span> <span class="pl-s1">f</span>.<span class="pl-en">solve</span>(<span class="pl-c1">1</span>, <span class="pl-s1">extrapolate</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)
<span class="pl-c"># array([-1.79965237e-07,  0.00000000e+00,  1.56105529e-16])</span>
<span class="pl-en">f</span>(<span class="pl-s1">rt</span>) <span class="pl-c1">-</span> <span class="pl-c1">1</span>
<span class="pl-c"># array([-1.62092562e-14,  0.00000000e+00,  0.00000000e+00])</span></pre></div>
<h3 dir="auto">Error message</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="--"><pre class="notranslate">--</pre></div>
<h3 dir="auto">SciPy/NumPy/Python version information</h3>
<p dir="auto">1.7.3 1.20.3 sys.version_info(major=3, minor=8, micro=12, releaselevel='final', serial=0)</p>