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
Returns: ValueError: operands could not be broadcast together with shapes (1000000,) (2,)
Additional context
Here's an example of how I fixed it:
if q is a number, convert to list to avoid unpack_single_arrays() error
Vectorize the ppf function
defquantile(self, q):
""" Quantile calculator Parameters ---------- q : float, list, array Quantile to be calculated. Must be between 0 and 1. Returns ------- x : float The inverse of the CDF at q. This is the probability that a random variable from the distribution is < q """iftype(q) in [int, float, np.float64]:
ifq<0orq>1:
raiseValueError("Quantile must be between 0 and 1")
else:
q=[q]
eliftype(q) in [list, np.ndarray]:
ifmin(q) <0ormax(q) >1:
raiseValueError("Quantile must be between 0 and 1")
else:
raiseValueError("Quantile must be of type float, list, array")
# ppf = self.__xvals_init[np.argmin(abs(self.__cdf_init - q))]defmixture_ppf(q):
returnself.__xvals_init[np.argmin(abs(self.__cdf_init-q))]
mixture_ppf_vec=np.vectorize(mixture_ppf)
ppf=mixture_ppf_vec(q)
returnunpack_single_arrays(ppf)
The text was updated successfully, but these errors were encountered:
Describe the bug
quantile() and inverse_SF() functions work fine with a single numeric input, but error out when provided an array or list
To Reproduce
Returns: ValueError: operands could not be broadcast together with shapes (1000000,) (2,)
Additional context
Here's an example of how I fixed it:
The text was updated successfully, but these errors were encountered: