def calculate_camp_concentration(r, t): t = Decimal(str(t)) r = Decimal(str(r)) n = Constants.N_OF_RELEASED_MOLECULES a = Decimal.exp(-((r ** Decimal(2)) / (Decimal(4) * Constants.DIFFUSION_CONSTANT * t))) b = Decimal.exp(-(t / Constants.TAU)) c = Decimal(4 * Decimal(math.pi) * t * Constants.DIFFUSION_CONSTANT) ** (Decimal(2) / Decimal(3)) return (n * a * b) / c
def Binomial_pmf(k,n,p): ''' calculates the pmf of binomial distribution ''' k_decimal = Decimal(k) n_decimal = Decimal(n) p_decimal = Decimal(p) tmp = Decimal(gammaln(n+1)-gammaln(k+1)-gammaln(n-k+1))+Decimal(k_decimal*p_decimal.ln()+(n_decimal-k_decimal)*Decimal(1-p_decimal).ln()) return tmp.exp()