def inv_cdf_dlf(p, A, m1, a1, m2, a2, start=-26, end=-15):
'''
Inverse Cumulative Schechter function. Second LF is set to be 2*A of first LF.
@param p: probability
@param A: Scale factor
@param m1: Knee of distribution 1
@param a1: Faint-end turnover of first lf
@param m2: Knee of distribution 2
@param a2: Faint-end turnover of second lf
@param start: Brightest magnitude
@param end: Faintest possible magnitude
@return Magnitude associated with cdf probability p
'''
def get_root(p):
return root(lambda x: cdf_dlf(x,A,m1,a1,m2,a2,start)-p, (start + end)/2).x[0]
if np.isscalar(p):
return get_root(p)
else:
return np.fromiter(map(get_root,p),np.float,count=len(p))
评论列表
文章目录