Код: Выделить всё
import numpy as np
from scipy import special
from scipy.stats import *
import scipy.stats
import scipy.integrate as integrate
class truncErfc_gen(rv_continuous):
''' Class for a truncated complementary error function
a and b are bounds
'''
def _argcheck(self, a, b): return (a < b)
def _get_support(self, a, b): return a, b
def _pdf(self, x, a, b): return special.erfc(x) / integrate.quad(special.erfc(x), a, b)[0] # Normalize the function over its bounds
truncErfc = truncErfc_gen(name='truncErfc', momtype=1)
x = np.linspace(-1, 10, 1000)
y = truncErfc.pdf(x, a=0., b=10.)
Код: Выделить всё
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Есть предложения?
Подробнее здесь: https://stackoverflow.com/questions/784 ... stribution