コード例 #1
0
def get_fixation_unconstrained_quad(S, d):
    sign_S = numpy.sign(S)
    D = d * sign_S
    H = numpy.zeros_like(S)
    for i in range(H.shape[0]):
        for j in range(H.shape[1]):
            H[i, j] = 1. / kimrecessive.denom_quad(0.5 * S[i, j], D[i, j])
    return H
コード例 #2
0
def get_fixation_kacser_quad(S, d, log_kb):
    soft_sign_S = numpy.tanh(numpy.exp(log_kb) * S)
    D = d * soft_sign_S
    H = numpy.zeros_like(S)
    for i in range(H.shape[0]):
        for j in range(H.shape[1]):
            H[i, j] = 1. / kimrecessive.denom_quad(0.5 * S[i, j], D[i, j])
    return H
コード例 #3
0
def get_fixation_kacser_quad(S, d, log_kb):
    soft_sign_S = numpy.tanh(numpy.exp(log_kb)*S)
    D = d * soft_sign_S
    H = numpy.zeros_like(S)
    for i in range(H.shape[0]):
        for j in range(H.shape[1]):
            H[i, j] = 1. / kimrecessive.denom_quad(
                    0.5*S[i, j], D[i, j])
    return H
コード例 #4
0
def get_fixation_unconstrained_quad(S, d):
    sign_S = numpy.sign(S)
    D = d * sign_S
    H = numpy.zeros_like(S)
    for i in range(H.shape[0]):
        for j in range(H.shape[1]):
            H[i, j] = 1. / kimrecessive.denom_quad(
                    0.5*S[i, j], D[i, j])
    return H
コード例 #5
0
ファイル: mle-recessive.py プロジェクト: BIGtigr/xgcode
def get_fixation_unconstrained_kb_quad(S, d, log_kb):
    """
    Use numerical quadrature.
    Do not bother trying to use algopy for this.
    """
    soft_sign_S = numpy.tanh(numpy.exp(log_kb) * S)
    D = d * soft_sign_S
    H = numpy.zeros_like(S)
    for i in range(H.shape[0]):
        for j in range(H.shape[1]):
            H[i, j] = 1. / kimrecessive.denom_quad(0.5 * S[i, j], D[i, j])
    return H
コード例 #6
0
def get_fixation_unconstrained_kb_quad(S, d, log_kb):
    """
    Use numerical quadrature.
    Do not bother trying to use algopy for this.
    """
    soft_sign_S = numpy.tanh(numpy.exp(log_kb)*S)
    D = d * soft_sign_S
    H = numpy.zeros_like(S)
    for i in range(H.shape[0]):
        for j in range(H.shape[1]):
            H[i, j] = 1. / kimrecessive.denom_quad(
                    0.5*S[i, j], D[i, j])
    return H
コード例 #7
0
ファイル: 20121028a.py プロジェクト: BIGtigr/xgcode
def get_relative_error_e3(c, d):
    x = kimrecessive.denom_quad(c, d)
    y = kimrecessive.denom_hyp2f0_b(c, d)
    z = (y-x) / x
    return refilter(z)
コード例 #8
0
ファイル: 20121028a.py プロジェクト: BIGtigr/xgcode
def get_relative_error_d(c, d):
    x = kimrecessive.denom_quad(c, d)
    y = kimrecessive.denom_near_genic_combo(c, d)
    z = (y-x) / x
    return refilter(z)
コード例 #9
0
ファイル: 20121028a.py プロジェクト: BIGtigr/xgcode
def get_relative_error_c(c, d):
    x = kimrecessive.denom_quad(c, d)
    y = kimrecessive.denom_piecewise(c, d)
    z = (y-x) / x
    return refilter(z)
コード例 #10
0
ファイル: 20121028a.py プロジェクト: BIGtigr/xgcode
def get_relative_error_a(c, d):
    x = kimrecessive.denom_quad(c, d)
    y = kimrecessive.denom_not_genic(c, d)
    z = (y-x) / x
    return refilter(z)
コード例 #11
0
ファイル: 20121028a.py プロジェクト: BIGtigr/xgcode
def do_integration_demo():
    N = 101
    #d = np.linspace(-5, 5, N) / 10000.
    #c = np.linspace(-100, 100, N) / 10.
    #d = np.linspace(-5, 5, N) / 3.
    #c = np.linspace(-100, 100, N) / 3.
    d = np.linspace(-5, 5, N)
    c = np.linspace(-100, 100, N)
    #d = np.linspace(-1, 1, N) * 0.25
    #c = np.linspace(-1, 1, N) * 0.02
    #d = np.linspace(-3, 3, N) / 10.
    #c = np.linspace(-30, 30, N) / 10.
    #d = np.linspace(-3, 3, N) / 10000.
    #c = np.linspace(-30, 30, N) / 10000.
    #d = np.linspace(-3, 3, N)
    #c = np.linspace(-30, 30, N)
    #d = np.linspace(-4, 4, N)
    #c = np.linspace(-40, 40, N)
    #c = np.linspace(-20, 20, N)
    #d = np.linspace(-.2, .2, N)
    #c = np.linspace(-100, 100, N)
    #c = np.linspace(-200, 200, N)
    #dc, dd = 0.001, 0.001
    #c = np.arange(1.-0.05, 1.+0.05, dc)
    #d = np.arange(1.-0.05, 1.+0.05, dd)
    ##dc, dd = 0.005, 0.005
    ##c = np.arange(0, 0.3, dc)
    ##d = np.arange(-0.2, 0.2, dd)


    """
    Z = np.zeros((len(d), len(c)))
    for j, dj in enumerate(d):
        for i, ci in enumerate(c):
            Z[j, i] = get_relative_error_a(ci, dj)
    im = plt.imshow(Z, cmap=plt.cm.jet)
    plt.show()
    """

    """
    Z = np.zeros((len(d), len(c)))
    for j, dj in enumerate(d):
        for i, ci in enumerate(c):
            Z[j, i] = get_relative_error_b(ci, dj)
    im = plt.imshow(Z, cmap=plt.cm.jet)
    plt.show()
    """

    """
    Z = np.zeros((len(d), len(c)))
    for j, dj in enumerate(d):
        for i, ci in enumerate(c):
            Z[j, i] = get_relative_error_c(ci, dj)
    im = plt.imshow(Z, cmap=plt.cm.jet)
    plt.show()
    """

    """
    Z = np.zeros((len(d), len(c)))
    for j, dj in enumerate(d):
        for i, ci in enumerate(c):
            Z[j, i] = get_relative_error_d(ci, dj)
    im = plt.imshow(Z, cmap=plt.cm.jet)
    plt.show()
    """

    """
    Z = np.zeros((len(d), len(c)))
    for j, dj in enumerate(d):
        for i, ci in enumerate(c):
            Z[j, i] = get_relative_error_e1(ci, dj)
    im = plt.imshow(Z, cmap=plt.cm.jet)
    plt.show()

    Z = np.zeros((len(d), len(c)))
    for j, dj in enumerate(d):
        for i, ci in enumerate(c):
            Z[j, i] = get_relative_error_e2(ci, dj)
    im = plt.imshow(Z, cmap=plt.cm.jet)
    plt.show()

    Z = np.zeros((len(d), len(c)))
    for j, dj in enumerate(d):
        for i, ci in enumerate(c):
            Z[j, i] = get_relative_error_e3(ci, dj)
    im = plt.imshow(Z, cmap=plt.cm.jet)
    plt.show()

    Z = np.zeros((len(d), len(c)))
    for j, dj in enumerate(d):
        for i, ci in enumerate(c):
            Z[j, i] = get_relative_error_e4(ci, dj)
    im = plt.imshow(Z, cmap=plt.cm.jet)
    plt.show()

    Z = np.zeros((len(d), len(c)))
    for j, dj in enumerate(d):
        for i, ci in enumerate(c):
            Z[j, i] = get_relative_error_e6(ci, dj)
    im = plt.imshow(Z, cmap=plt.cm.jet)
    plt.show()
    """

    Z = np.zeros((len(d), len(c)))
    W = np.zeros((len(d), len(c)))
    quad_x, quad_w = kimrecessive.precompute_quadrature(0, 1, 101)
    for j, dj in enumerate(d):
        for i, ci in enumerate(c):
            x = kimrecessive.denom_quad(ci, dj)
            #y = kimrecessive.denom_poly_b(ci, dj)
            #y = kimengine.denom_poly(ci, dj)
            #y = kimrecessive.denom_hyperu_b(ci, dj)
            #y = kimrecessive.denom_erfcx_b(ci, dj)
            y = kimrecessive.denom_fixed_quad(ci, dj, quad_x, quad_w)
            #y = kimrecessive.denom_combo_b(ci, dj)
            w = abs(y - x) / abs(x)
            W[j, i] = w
            Z[j, i] = refilter(w)
    print numpy.max(W)
    import matplotlib.pyplot as plt
    fig = plt.figure()
    im = plt.imshow(Z, cmap=plt.cm.jet)
    plt.show()
コード例 #12
0
ファイル: 20121028a.py プロジェクト: BIGtigr/xgcode
def get_relative_error_e6(c, d):
    x = kimrecessive.denom_quad(c, d)
    y = kimrecessive.denom_combo_b(c, d)
    z = (y - x) / x
    return refilter(z)