def pdf(x, mu=0, sigma=1): """ Log-normal distribution probability density function. """ _validate_sigma(sigma) if x <= 0: return mpmath.mp.zero x = mpmath.mpf(x) lnx = mpmath.log(x) return mpmath.npdf(lnx, mu, sigma) / x
def pdf(x, a, b): """ PDF of the truncated standard normal distribution. """ _validate_params(a, b) if x < a or x > b: return mpmath.mp.zero with mpmath.extradps(5): x = mpmath.mpf(x) a = mpmath.mpf(a) b = mpmath.mpf(b) delta = _norm_delta_cdf(a, b) return mpmath.npdf(x) / delta
def var(chi, c): """ Variance of the ARGUS distribution. """ if c <= 0: raise ValueError('c must be positive') if chi <= 0: raise ValueError('chi must be positive') with mpmath.extradps(5): chi = mpmath.mpf(chi) c = mpmath.mpf(c) mu = mean(chi, c) t1 = c**2 * (mpmath.mp.one - 3 / chi**2 + chi * mpmath.npdf(chi) / _psi(chi)) return t1 - mu**2
def pHit(z, zReal, desvioHit=(Parametros.DESVIO_HIT), alcanceMax=(Parametros.ALCANCE_MAXIMO)): if (0 <= z <= alcanceMax): #n = (mp.ncdf(alcanceMax,zReal,desvioHit) - mp.ncdf(0,zReal,desvioHit))**-1 #ta errado ''' Usar uma area e calcular ncdf ao invez de npdf a probabilidade de um ponto eh zero, mas a valor da funcao nao eh ''' #print "N ", n aux = 0 #for i in range(alcanceMax*10): # aux += mp.npdf(float(i)/10,zReal,desvioHit) #print "AREA ", aux #n = aux**-1 n = 0.1 #print "Com: ", (mp.ncdf(z+0.01,zReal,desvioHit - mp.ncdf(z-0.01,zReal,desvioHit))), "Sem: ", n*mp.npdf(z,zReal,desvioHit) return n * mp.npdf(z, zReal, desvioHit) #return (mp.ncdf(z+0.01,zReal,desvioHit - mp.ncdf(z-0.01,zReal,desvioHit))) else: return 0
def _mu1(x): return mp.npdf(x, mu=1, sigma=sigma)
def _mu0(x): return mp.npdf(x, mu=0, sigma=sigma)
def f49(x): # hazard return mpmath.npdf(x) / (1 - mpmath.ncdf(x))
def f47(x): # erf_Z return mpmath.npdf(x)
def mu0(x): return mpmath.npdf(x, mu=0, sigma=sigma)
def pdf(x, mu=0, sigma=1): """ Normal distribution probability density function. """ # Defined here for consistency, but this is just mpmath.npdf return mpmath.npdf(x, mu, sigma)
def _psi(chi): return mpmath.ncdf(chi) - chi * mpmath.npdf(chi) - mpmath.mpf('0.5')