Skip to content
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

Q: Why are distributions not broadcastable? #116

Open
ikrommyd opened this issue Jan 16, 2025 · 0 comments
Open

Q: Why are distributions not broadcastable? #116

ikrommyd opened this issue Jan 16, 2025 · 0 comments

Comments

@ikrommyd
Copy link
Contributor

ikrommyd commented Jan 16, 2025

It must have been a design choice to make distributions not broadcast their parameters right? Why is that in particular?
I personally find the scipy broadcasting ability on parameters very useful sometimes

from numba_stats import norm as nbnorm
from scipy.stats import norm as spnorm
import numpy as np

x = np.array([0.0, 1.1])
mu = np.array([1.0, 2.0])
sigma = np.array([3.0, 4.0])

print(spnorm.pdf(x, mu, sigma))
print(nbnorm.pdf(x, mu, sigma))

gives

[0.12579441 0.0972427 ]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[1], line 10
      7 sigma = np.array([3.0, 4.0])
      9 print(spnorm.pdf(x, mu, sigma))
---> 10 print(nbnorm.pdf(x, mu, sigma))

File <string>:3, in pdf(x, loc, scale)

File ~/fun/numba-stats/src/numba_stats/_util.py:90, in _wrap.<locals>.outer(first, *rest)
     88 if first.dtype.kind != "f":
     89     first = first.astype(float)
---> 90 return fn(first, *rest).reshape(shape)

File ~/miniforge3/envs/zfit-dev/lib/python3.12/site-packages/numba/core/dispatcher.py:658, in _DispatcherBase._explain_matching_error(self, *args, **kws)
    655 args = [self.typeof_pyval(a) for a in args]
    656 msg = ("No matching definition for argument type(s) %s"
    657        % ', '.join(map(str, args)))
--> 658 raise TypeError(msg)

TypeError: No matching definition for argument type(s) array(float64, 1d, C), array(float64, 1d, C), array(float64, 1d, C)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant