def pr5b2(dim, cutoff): data = numpy.loadtxt("data/ps8/data2", dtype=numpy.float64) ms = tispy.lyap_k("-d", 155, "-m", dim, "-M", dim, input=data) pargs = cut(ms[:, 0], ms[:, 1]) total = 0.0 count = len(pargs) / 2 for i in xrange(0, len(pargs), 2): xs = 0.31 * pargs[i][:cutoff] ys = pargs[i + 1][:cutoff] ps = numpy.polyfit(xs, ys, 1) total += ps[0] print "Found Lyapunov exponent: {0:.6f}".format(total / count)
def pr5b2(dim, cutoff): data = numpy.loadtxt('data/ps8/data2', dtype=numpy.float64) ms = tispy.lyap_k('-d', 155, '-m', dim, '-M', dim, input=data) pargs = cut(ms[:, 0], ms[:, 1]) total = 0.0 count = len(pargs) / 2 for i in xrange(0, len(pargs), 2): xs = 0.31 * pargs[i][:cutoff] ys = pargs[i + 1][:cutoff] ps = numpy.polyfit(xs, ys, 1) total += ps[0] print 'Found Lyapunov exponent: {0:.6f}'.format(total / count)
def pr5(dim=8, file_prefix=None): data = numpy.loadtxt('data/ps8/data2', dtype=numpy.float64) ms = tispy.lyap_k('-d', 155, '-m', dim, '-M', dim, input=data) pargs = cut(ms[:, 0], ms[:, 1]) # Find the average slope of the first two points. total = 0.0 count = len(pargs) / 2 for i in xrange(0, len(pargs), 2): [x1, x2] = pargs[i][:2] [y1, y2] = pargs[i + 1][:2] total += (y2 - y1) / (0.31 * (x2 - x1)) print 'Found Lyapunov exponent: {0:.6f}'.format(total / count) plot.render(*pargs, xlabel='Iterations', ylabel='Logarithm of the Stretching Factor', title='Calculating the Lyapunov Exponent', file_prefix=suffixed(file_prefix, '_4'))
def pr5(dim=8, file_prefix=None): data = numpy.loadtxt("data/ps8/data2", dtype=numpy.float64) ms = tispy.lyap_k("-d", 155, "-m", dim, "-M", dim, input=data) pargs = cut(ms[:, 0], ms[:, 1]) # Find the average slope of the first two points. total = 0.0 count = len(pargs) / 2 for i in xrange(0, len(pargs), 2): [x1, x2] = pargs[i][:2] [y1, y2] = pargs[i + 1][:2] total += (y2 - y1) / (0.31 * (x2 - x1)) print "Found Lyapunov exponent: {0:.6f}".format(total / count) plot.render( *pargs, xlabel="Iterations", ylabel="Logarithm of the Stretching Factor", title="Calculating the Lyapunov Exponent", file_prefix=suffixed(file_prefix, "_4") )
def pr6x1(tau, file_prefix=None): lfunc = lorenz.lorenz(16, 45, 4) ts, vs = rungekutta.rk4( lfunc, 0.0, numpy.array([-13.0, -12.0, 52.0], dtype=numpy.float64), 0.001, 30000) xs = vs.transpose()[:, 0] data = numpy.array(zip(xs, ts), dtype=numpy.float64) ms = tispy.lyap_k('-d', int(tau), '-m', 7, '-M', 7, input=data) pargs = cut(ms[:, 0], ms[:, 1]) total = 0.0 count = len(pargs) / 2 for i in xrange(0, len(pargs), 2): xs = 0.31 * pargs[i][:50] ys = pargs[i + 1][:50] ps = numpy.polyfit(xs, ys, 1) total += ps[0] print 'Lorenz lyapunov exponent: {0}'.format(total / count) plot.render(*pargs, xlabel='Iterations', ylabel='Logarithm of the Stretching Factor', title='Calculating the Lyapunov Exponent', file_prefix=suffixed(file_prefix, '_7'))
def pr6x1(tau, file_prefix=None): lfunc = lorenz.lorenz(16, 45, 4) ts, vs = rungekutta.rk4(lfunc, 0.0, numpy.array([-13.0, -12.0, 52.0], dtype=numpy.float64), 0.001, 30000) xs = vs.transpose()[:, 0] data = numpy.array(zip(xs, ts), dtype=numpy.float64) ms = tispy.lyap_k("-d", int(tau), "-m", 7, "-M", 7, input=data) pargs = cut(ms[:, 0], ms[:, 1]) total = 0.0 count = len(pargs) / 2 for i in xrange(0, len(pargs), 2): xs = 0.31 * pargs[i][:50] ys = pargs[i + 1][:50] ps = numpy.polyfit(xs, ys, 1) total += ps[0] print "Lorenz lyapunov exponent: {0}".format(total / count) plot.render( *pargs, xlabel="Iterations", ylabel="Logarithm of the Stretching Factor", title="Calculating the Lyapunov Exponent", file_prefix=suffixed(file_prefix, "_7") )
def pr5b1(dim): data = numpy.loadtxt('data/ps8/data2', dtype=numpy.float64) ms = tispy.lyap_k('-d', 155, '-m', dim, '-M', dim, input=data) pargs = tuple([xs[:11] for xs in cut(ms[:, 0], ms[:, 1])]) plot.render(*pargs)
def pr5b1(dim): data = numpy.loadtxt("data/ps8/data2", dtype=numpy.float64) ms = tispy.lyap_k("-d", 155, "-m", dim, "-M", dim, input=data) pargs = tuple([xs[:11] for xs in cut(ms[:, 0], ms[:, 1])]) plot.render(*pargs)