def Beta(a, b, lo=0, up=1): R""" Beta Probability Distribution Parameters ---------- a : float, Dist First shape parameter a > 0 b : float, Dist Second shape parameter b > 0 lo : float, Dist Lower threshold up : float, Dist Upper threshold Examples -------- >>> cp.seed(1000) >>> f = cp.Beta(2, 2, 2, 3) >>> q = np.linspace(0,1,6)[1:-1] >>> print f.inv(q) [ 2.28714073 2.43293108 2.56706892 2.71285927] >>> print f.fwd(f.inv(q)) [ 0.2 0.4 0.6 0.8] >>> print f.sample(4) [ 2.60388804 2.21123197 2.86505298 2.48812537] >>> print f.mom(1) 2.5 """ dist = co.beta(a, b) * (up - lo) + lo dist.addattr(str="Beta(%s,%s,%s,%s)" % (a, b, lo, up)) return dist
def Beta(a, b, lo=0, up=1): R""" Beta Probability Distribution Parameters ---------- a : float, Dist First shape parameter a > 0 b : float, Dist Second shape parameter b > 0 lo : float, Dist Lower threshold up : float, Dist Upper threshold Examples -------- >>> cp.seed(1000) >>> f = cp.Beta(2, 2, 2, 3) >>> q = np.linspace(0,1,6)[1:-1] >>> print f.inv(q) [ 2.28714073 2.43293108 2.56706892 2.71285927] >>> print f.fwd(f.inv(q)) [ 0.2 0.4 0.6 0.8] >>> print f.sample(4) [ 2.60388804 2.21123197 2.86505298 2.48812537] >>> print f.mom(1) 2.5 """ dist = co.beta(a, b)*(up-lo) + lo dist.addattr(str="Beta(%s,%s,%s,%s)" % (a,b,lo,up)) return dist
def Wigner(radius=1, shift=0): """ Wigner (semi-circle) distribution radius : float, Dist radius of the semi-circle (scale) shift : float, Dist location of the origen (location) """ dist = radius*(2*co.beta(1.5,1.5)-1) + shift dist.addattr(str="Wigner(%s,%s)" % (radius, shift)) return dist
def Wigner(radius=1, shift=0): """ Wigner (semi-circle) distribution radius : float, Dist radius of the semi-circle (scale) shift : float, Dist location of the origen (location) """ dist = radius * (2 * co.beta(1.5, 1.5) - 1) + shift dist.addattr(str="Wigner(%s,%s)" % (radius, shift)) return dist
def Arcsinus(shape=0.5, lo=0, up=1): """ Generalized Arc-sinus distribution shape : float, Dist Shape parameter where 0.5 is the default non-generalized case. lo : float, Dist Lower threshold up : float, Dist Upper threshold """ dist = co.beta(shape, 1-shape)*(up-lo) + lo dist.addattr(str="Arcsinus(%s,%s,%s)" % (shape, lo, up)) return dist
def Arcsinus(shape=0.5, lo=0, up=1): """ Generalized Arc-sinus distribution shape : float, Dist Shape parameter where 0.5 is the default non-generalized case. lo : float, Dist Lower threshold up : float, Dist Upper threshold """ dist = co.beta(shape, 1 - shape) * (up - lo) + lo dist.addattr(str="Arcsinus(%s,%s,%s)" % (shape, lo, up)) return dist
def Powerlaw(shape=1, lo=0, up=1): """ Powerlaw distribution Parameters ---------- shape : float, Dist Shape parameter lo : float, Dist Location of lower threshold up : float, Dist Location of upper threshold """ dist = co.beta(shape, 1)*(up-lo) + lo dist.addattr(str="Powerlaw(%s,%s,%s)"%(shape, lo, up)) return dist
def Powerlaw(shape=1, lo=0, up=1): """ Powerlaw distribution Parameters ---------- shape : float, Dist Shape parameter lo : float, Dist Location of lower threshold up : float, Dist Location of upper threshold """ dist = co.beta(shape, 1) * (up - lo) + lo dist.addattr(str="Powerlaw(%s,%s,%s)" % (shape, lo, up)) return dist