Beispiel #1
0
    def CalcG_prime_d(d, c_min, c_max, c1Len, c2Len, readLen):

        term1 = -0.5 * (normal.erf(
            (c_min + c_max + d + 1 - mean) /
            (2**0.5 * float(stdDev))) + normal.erf(
                (d + 2 * readLen - 1 - mean) / (2**0.5 * float(stdDev))))
        term2 = +0.5 * (normal.erf(
            (d + c_max + readLen - mean) /
            (2**0.5 * float(stdDev))) + normal.erf(
                (d + c_min + readLen - mean) / (2**0.5 * float(stdDev))))
        g_prime_d = term1 + term2
        return g_prime_d
Beispiel #2
0
    def CalcGd(d, c1Len, c2Len, readLen):
        #term 1,2 and 3 denodes what part of the function we are integrating term1 for first (ascending), etc...
        term1 = (c_min - readLen + 1) / 2.0 * (normal.erf((c_max + d + readLen - mean) / ((2 ** 0.5) * stdDev)) - normal.erf((c_min + d + readLen - mean) / ((2 ** 0.5) * stdDev)))

        term2 = (c_min + c_max + d - mean + 1) / 2.0 * (normal.erf((c_min + c_max + d + 1 - mean) / (2 ** 0.5 * float(stdDev))) - normal.erf((c_max + readLen + d - mean) / (2 ** 0.5 * float(stdDev))))

        term3 = (d + 2 * readLen - mean - 1) / 2.0 * (normal.erf((d + 2 * readLen - 1 - mean) / (2 ** 0.5 * float(stdDev))) - normal.erf((c_min + d + readLen - mean) / ((2 ** 0.5) * stdDev)))

        term4 = stdDev / ((2 * pi) ** 0.5) * ( exp( (-((c_min + c_max + d + 1 - mean) ** 2) / (float(2 * stdDev ** 2)))) + exp( (-((d + 2 * readLen - 1 - mean) ** 2) / (float(2 * stdDev ** 2)))))

        term5 = -stdDev / ((2 * pi) ** 0.5) * (exp( (-((c_max + readLen + d - mean) ** 2) / (float(2 * stdDev ** 2)))) + exp( (-((c_min + readLen + d - mean) ** 2) / (float(2 * stdDev ** 2)))))

        g_d = term1 + term2 + term3 + term4 + term5
        return g_d
Beispiel #3
0
 def Denom(d, readLen, mean, stdDev):
     first = -(
         (pi / 2)**0.5) * (d + 2 * readLen - mean - 1) * (1 + normal.erf(
             (mean - d - 2 * readLen + 1) / (2**0.5 * float(stdDev))))
     second = stdDev * exp(
         (-((mean - d - 2 * readLen + 1)**2) / (float(2 * stdDev**2))))
     denom = first + second
     return denom
Beispiel #4
0
    def Denominator(d, reflen, readLen):
        #term 1,2 and 3 denodes what part of the function we are integrating term1 for first (ascending), etc...

        #term1 = (c_min - readLen + 1) / 2.0 * (normal.erf((c_max + d + readLen - mean) / ((2 ** 0.5) * stdDev)) - normal.erf((c_min + d + readLen - mean) / ((2 ** 0.5) * stdDev)))

        #term2 = (c_min + c_max + d - mean + 1) / 2.0 * (normal.erf((c_min + c_max + d + 1 - mean) / (2 ** 0.5 * float(stdDev))) - normal.erf((c_max + readLen + d - mean) / (2 ** 0.5 * float(stdDev))))

        term3 = ((d + 2 * readLen - mean - 1) / 2.0) * (normal.erf(
            (d + 2 * readLen - 1 - mean) /
            (2**0.5 * float(stdDev))) - normal.erf(
                (reflen + d + 1 - mean) / ((2**0.5) * stdDev)))

        term4 = stdDev / ((2 * pi)**0.5) * (-exp(-(
            (reflen + d + 1 - mean)**2) / (float(2 * stdDev**2))) + exp(-(
                (d + 2 * readLen - 1 - mean)**2) / (float(2 * stdDev**2))))

        #term5 = -stdDev / ((2 * pi) ** 0.5) * (exp(-((c_max + readLen + d - mean) ** 2) / (float(2 * stdDev ** 2))) + exp(-((c_min + readLen + d - mean) ** 2) / (float(2 * stdDev ** 2))))
        g_d = term3 + term4
        return g_d
def g_prim_d(x, d, mu, sigma, c_min, c_max, r):
    # in the middle part (roof of triangle house, between c_min and c_max)
    if c_max+d+r-x >= 0 and c_min+d+r-x <= 0:
        # print("lol")
        return 0

    # x is large, on the down slope of the triangle house
    elif c_max+d+r-x < 0 and c_min + c_max + d - x > -1:
        #print 'loolz', normal.erf((mu-math_log_if_pos(x))+sigma**2/(sqrt(2) * sigma)), x #normal.erf((mu-math_log_if_pos(x))/(math.sqrt(2.0)*sigma))
        # print("ok")
        return 0.5 * normal.erf((math_log_if_pos(x) - mu)/(sqrt(2) * sigma))

    # x is small, beginning of triangle house
    elif d+2*r-x < 1 and c_min+d+r-x > 0:
        #print 'laal', normal.erf(((mu-math_log_if_pos(x))+sigma**2)/(math.sqrt(2.0)*sigma))
        return -0.5 * normal.erf((math_log_if_pos(x) - mu)/(sqrt(2) * sigma))
        # print("ok2")
    else:
        # print("lol2")
        return 0
def gd(x, d, mu, sigma, c_min, c_max, r):
    # in the middle part (roof of triangle house, between c_min and c_max)
    if c_max+d+r-x >= 0 and c_min+d+r-x <= 0:
        multiplier_height = max((c_min-r+1)/2.0, 1)
        return multiplier_height * normal.erf((math_log_if_pos(x)-mu)/(math.sqrt(2.0)*sigma))
        # return (c_min-r+1)/2.0 * normal.erf((math_log_if_pos(x)-mu)/(math.sqrt(2.0)*sigma))

    # x is large, on the down slope of the triangle house
    elif c_max+d+r-x < 0 and c_min + c_max + d - x > -1:
        #print 'loolz', normal.erf((mu-math_log_if_pos(x))+sigma**2/(sqrt(2) * sigma)), x #normal.erf((mu-math_log_if_pos(x))/(math.sqrt(2.0)*sigma))
        return 1/2.0 * (math.exp(sigma**2/2.0 + mu) * normal.erf((mu-math_log_if_pos(x)+sigma**2)/(sqrt(2) * sigma)) - (c_min+c_max+d+1)*normal.erf((mu-math_log_if_pos(x))/(math.sqrt(2.0)*sigma)))

    # x is small, beginning of triangle house
    elif d+2*r-x < 1 and c_min+d+r-x > 0:
        #print 'laal', normal.erf(((mu-math_log_if_pos(x))+sigma**2)/(math.sqrt(2.0)*sigma))
        return -1/2.0 * (math.exp(sigma**2/2.0 + mu) * normal.erf(((mu-math_log_if_pos(x))+sigma**2)/(math.sqrt(2.0)*sigma)) - (d+2*r-1)*normal.erf((mu-math_log_if_pos(x)) / (math.sqrt(2.0)*sigma)))

    else:
        # print("OMG")
        return 0.0
Beispiel #7
0
def g_prim_d(x, d, mu, sigma, c_min, c_max, r):
	# in the middle part (roof of triangle house, between c_min and c_max)
	if c_max+d+r-x >= 0 and c_min+d+r-x <= 0:
		# print("lol")
		return 0

	# x is large, on the down slope of the triangle house
	elif c_max+d+r-x < 0 and c_min + c_max + d - x > -1:
		#print 'loolz', normal.erf((mu-math_log_if_pos(x))+sigma**2/(sqrt(2) * sigma)), x #normal.erf((mu-math_log_if_pos(x))/(math.sqrt(2.0)*sigma))
		# print("ok")
		return 0.5 * normal.erf((math_log_if_pos(x) - mu)/(sqrt(2) * sigma))

	# x is small, beginning of triangle house
	elif d+2*r-x < 1 and c_min+d+r-x > 0:
		#print 'laal', normal.erf(((mu-math_log_if_pos(x))+sigma**2)/(math.sqrt(2.0)*sigma))
		return -0.5 * normal.erf((math_log_if_pos(x) - mu)/(sqrt(2) * sigma))
		# print("ok2")
	else:
		# print("lol2")
		return 0
Beispiel #8
0
def gd(x, d, mu, sigma, c_min, c_max, r):
	# in the middle part (roof of triangle house, between c_min and c_max)
	if c_max+d+r-x >= 0 and c_min+d+r-x <= 0:
		multiplier_height = max((c_min-r+1)/2.0, 1)
		return multiplier_height * normal.erf((math_log_if_pos(x)-mu)/(math.sqrt(2.0)*sigma))
		# return (c_min-r+1)/2.0 * normal.erf((math_log_if_pos(x)-mu)/(math.sqrt(2.0)*sigma))

	# x is large, on the down slope of the triangle house
	elif c_max+d+r-x < 0 and c_min + c_max + d - x > -1:
		#print 'loolz', normal.erf((mu-math_log_if_pos(x))+sigma**2/(sqrt(2) * sigma)), x #normal.erf((mu-math_log_if_pos(x))/(math.sqrt(2.0)*sigma))
		return 1/2.0 * (math.exp(sigma**2/2.0 + mu) * normal.erf((mu-math_log_if_pos(x)+sigma**2)/(sqrt(2) * sigma)) - (c_min+c_max+d+1)*normal.erf((mu-math_log_if_pos(x))/(math.sqrt(2.0)*sigma)))

	# x is small, beginning of triangle house
	elif d+2*r-x < 1 and c_min+d+r-x > 0:
		#print 'laal', normal.erf(((mu-math_log_if_pos(x))+sigma**2)/(math.sqrt(2.0)*sigma))
		return -1/2.0 * (math.exp(sigma**2/2.0 + mu) * normal.erf(((mu-math_log_if_pos(x))+sigma**2)/(math.sqrt(2.0)*sigma)) - (d+2*r-1)*normal.erf((mu-math_log_if_pos(x)) / (math.sqrt(2.0)*sigma)))

	else:
		# print("OMG")
		return 0.0
Beispiel #9
0
 def Nom(z, mean, stdDev):
     nom = -(1 + normal.erf((mean - d - 2 * readLen + 1) /
                            (2**0.5 * float(stdDev)))) * (pi / 2)**0.5
     return nom
Beispiel #10
0
def erf_norm(x, mu, sigma):
    return normal.erf((x - mu) / (sqrt(2.0) * sigma))
Beispiel #11
0
    def Nominator(d, c_min, c_max, c1Len, c2Len, readLen):

        term1 = -0.5 * (normal.erf((c_min + c_max + d + 1 - mean) / (2 ** 0.5 * float(stdDev))) + normal.erf((d + 2 * readLen - 1 - mean) / (2 ** 0.5 * float(stdDev))))
        term2 = +0.5 * (normal.erf((d + c_max + readLen - mean) / (2 ** 0.5 * float(stdDev))) + normal.erf((d + c_min + readLen - mean) / (2 ** 0.5 * float(stdDev))))
        g_prime_d = term1 + term2
        return -g_prime_d
Beispiel #12
0
 def Denom(d, readLen, mean, stdDev):
     first = -((pi / 2) ** 0.5) * (d + 2 * readLen - mean - 1) * (1 + normal.erf((mean - d - 2 * readLen + 1) / (2 ** 0.5 * float(stdDev))))
     second = stdDev * exp((-((mean - d - 2 * readLen + 1) ** 2) / (float(2 * stdDev ** 2))))
     denom = first + second
     return denom
Beispiel #13
0
 def Nom(z, mean, stdDev):
     nom = -(1 + normal.erf((mean - d - 2 * readLen + 1) / (2 ** 0.5 * float(stdDev)))) * (pi / 2) ** 0.5
     return nom
Beispiel #14
0
def erf_norm(x,mu,sigma):
    return normal.erf((x-mu)/(sqrt(2.0)*sigma))