Пример #1
0
def p_price(V, analytical, spots, vars, marker_idx=0, label="", bad=False):
    surface(V, spots, vars)
    # wireframe(V - analytical, spots, vars)
    if bad:
        label += " - bad analytical!"
    pylab.title("Price (%s)" % label)
    pylab.xlabel("Var")
    pylab.ylabel("% of strike")
    pylab.show()
Пример #2
0
def p_price(V, analytical, spots, vars, marker_idx=0, label="", bad=False):
    surface(V, spots, vars)
    # wireframe(V - analytical, spots, vars)
    if bad:
        label += " - bad analytical!"
    pylab.title("Price (%s)" % label)
    pylab.xlabel("Var")
    pylab.ylabel("% of strike")
    pylab.show()
Пример #3
0
def p_relative_error(V, analytical, spots, vars, marker_idx=0, label=""):
    surface((V - analytical) / analytical, spots, vars)
    if BADANALYTICAL:
        label += " - bad analytical!"
    else:
        label += " - ||V - V*|| = %.2e" % np.linalg.norm(V - analytical)
    title("Relative Error in Price (%s)" % label)
    xlabel("Var")
    ylabel("% of strike")
    show()
Пример #4
0
def p_absolute_error(V, analytical, spots, vars, marker_idx=0, label="", bad=False):
    surface(V - analytical, spots, vars)
    # wireframe(V - analytical, spots, vars)
    if bad:
        label += " - bad analytical!"
    else:
        label += " - $||V - V*||^\infty = %.2e$" % max(abs(V-analytical).flat)
    pylab.title("Error in Price (%s)" % label)
    pylab.xlabel("Var")
    pylab.ylabel("% of strike")
    pylab.show()
Пример #5
0
def srf(n):
    global F1, F2, F1b, F2b, Fd, Fdb, Fh, Fhb, V, Vb, A
    a = {}
    a['i'] = (F1.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['d'] = (Fd.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['db'] = (Fdb.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['h'] = (Fh.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['hb'] = (Fhb.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['idb'] = (F1.grid.domain[-1] - Fdb.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['ihb'] = (F1.grid.domain[-1] - Fhb.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['dbhb'] = (Fdb.grid.domain[-1] - Fhb.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['v'] = (V, Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['vb'] = (Vb, Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['ab'] = (A, Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['hbab'] = (Fhb.grid.domain[-1] - A, Fh.grid.mesh[0], Fh.grid.mesh[1])
    vis.surface(*a[n])
Пример #6
0
def p_absolute_error(V,
                     analytical,
                     spots,
                     vars,
                     marker_idx=0,
                     label="",
                     bad=False):
    surface(V - analytical, spots, vars)
    # wireframe(V - analytical, spots, vars)
    if bad:
        label += " - bad analytical!"
    else:
        label += " - $||V - V*||^\infty = %.2e$" % max(
            abs(V - analytical).flat)
    pylab.title("Error in Price (%s)" % label)
    pylab.xlabel("Var")
    pylab.ylabel("% of strike")
    pylab.show()
Пример #7
0
def srf(n):
    global F1, F2, F1b, F2b, Fd, Fdb, Fh, Fhb, V, Vb, A
    a = {}
    a['i'] = (F1.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['d'] = (Fd.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['db'] = (Fdb.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['h'] = (Fh.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['hb'] = (Fhb.grid.domain[-1], Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['idb'] = (F1.grid.domain[-1] - Fdb.grid.domain[-1], Fh.grid.mesh[0],
                Fh.grid.mesh[1])
    a['ihb'] = (F1.grid.domain[-1] - Fhb.grid.domain[-1], Fh.grid.mesh[0],
                Fh.grid.mesh[1])
    a['dbhb'] = (Fdb.grid.domain[-1] - Fhb.grid.domain[-1], Fh.grid.mesh[0],
                 Fh.grid.mesh[1])
    a['v'] = (V, Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['vb'] = (Vb, Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['ab'] = (A, Fh.grid.mesh[0], Fh.grid.mesh[1])
    a['hbab'] = (Fhb.grid.domain[-1] - A, Fh.grid.mesh[0], Fh.grid.mesh[1])
    vis.surface(*a[n])