def A_plot_x_from_discrete_time(): # point 1 x0 = 0.1 _lambda = 1.7499 # от порядка к хаосу через перемежаемость 1.75 -> 1.7499 k = 1000 delta = 0 x_array = stf.iterate(_lambda, stf.logistic_map, k, delta, x0) # plt.plot(x_array, '.') # plt.grid() # plt.show() # plt.clf() fig = plt.figure() ax = fig.gca() the_plot, = ax.plot(x_array, ".") plt.ylabel("x values") plt.xlabel("discrete time") ax.legend() axlambd = plt.axes([0.15, 0.01, 0.65, 0.03], facecolor="b") lambd_slider = wgt.Slider(axlambd, "lambda", 1.748, 1.752, valinit=1.7499, valstep=0.00001, valfmt="%1.5f") def update_for_slider(val): lambd_local = lambd_slider.val the_plot.set_ydata(stf.iterate(lambd_local, stf.logistic_map, k, delta, x0)) fig.canvas.draw_idle() lambd_slider.on_changed(update_for_slider) plt.show() return x_array, k
def unique_for_lambda(_lambda): # point 1 x0 = 0.1 # от порядка к хаосу через перемежаемость 1.75 -> 1.7499 k = 8000 delta = 0 x_array = stf.iterate(_lambda, stf.logistic_map, k, delta, x0) # # x values # x_array, k = A_plot_x_from_discrete_time() precision = 10**-2 multiplier = np.int(1/precision) x_array_rounded = (np.array(x_array)*multiplier).astype(np.int) x_array_rounded = x_array_rounded[1:] # make array from 1001 to 1000 # we descretizes array to groups with group_size. laminar or toorbulent each group will be? # then we will understand where toorbulent and where laminar states is on whole array group_size = 20 # star from 20, 40, 100 grouped_array = x_array_rounded.reshape(len(x_array_rounded) // group_size, group_size) len_array = [len(np.unique(group)) for group in grouped_array] # from marked array we can find all laminar states apearing # if _len<(group_size//4) (if _len mini-unique_array is small) then state is laminar, otherwise it's chaotic, means turbulent mark_array = [1 if _len<(group_size//4) else 0 for _len in len_array] # print("lambda: ", _lambda," sum mark array: ", sum(mark_array)) # unique_array = np.unique( x_array_rounded ) return sum(mark_array)
def taskB_plot_iterdiag(): _lambda = 1.4011 k = 200 x0 = 0 # plot basic figures na = numpy.arange(-1, 1.00, 0.02) f_array = [stf.logistic_map(x, _lambda) for x in na] # parabola x = [x for x in na] zero_array = [0 for x in na] plt.plot(x, f_array) # parabola plt.plot(x, x) #diagonal plt.plot(x, zero_array) # x axes plt.plot(zero_array, x) # y axes x_array = stf.iterate(_lambda, stf.logistic_map, k, 0, x0) #print(x_array) # should be function for n in range(0, len(x_array) - 1): plt.vlines(x_array[n], x_array[n], x_array[n + 1], "b") plt.hlines(x_array[n + 1], x_array[n], x_array[n + 1], "b") plt.grid() plt.show() # plt.clf() #----------------------- def logistic(x, lam): return 1.0 - lam * x**2 def RG(fn, k): def make_next(fk): return lambda x: fk(fk(x * fk(fk(0)))) / fk(fk(0)) for _ in range(k): fn = make_next(fn) return fn rgs = [RG(lambda x: logistic(x, 1.401), k) for k in range(3)] xs = numpy.linspace(-1, 1) ys = lambda f: [f(x) for x in xs] plt.plot( xs, ys(rgs[0]), "r-", xs, ys(rgs[1]), "g-", xs, ys(rgs[2]), "b-", ) plt.grid() plt.show()
def unique_for_lambda(_lambda): # point 1 x0 = 0.1 # от порядка к хаосу через перемежаемость 1.75 -> 1.7499 k = 1000 delta = 0 x_array = stf.iterate(_lambda, stf.logistic_map, k, delta, x0) # # x values # x_array, k = A_plot_x_from_discrete_time() precision = 10**-4 multiplier = np.int(1/precision) x_array_rounded = (np.array(x_array)*multiplier).astype(np.int) unique_array = np.unique( x_array_rounded ) return len(unique_array)
def search_minimum_x(_lambda2_approximate ): # for 2**k iteration number, k - period number x_array = stf.iterate(_lambda2_approximate, stf.logistic_map, 2**k, 0, 0.1) return x_array[-1]
def allLambda(lmin, lmax, ld, *args): diagramList = [] _lambdaRow = numpy.arange(lmin, lmax, ld) for _lambda in _lambdaRow: diagramList.append(stf.iterate(_lambda, *args)) return _lambdaRow, diagramList
import numpy import matplotlib.pyplot as plt import sup_task_funcs as stf _lambda = 1.4011 iterate = 2000 delete_steps = 200 x0 = 0 x_array = stf.iterate(_lambda, stf.logistic_map, iterate, delete_steps, x0) def plot_itter_diag(x_array, _lambda): # plot basic figures na = numpy.arange(-1, 1.00, 0.02) f_array = [stf.logistic_map(x, _lambda) for x in na] # parabola x = na zero_array = [0 for x in na] plt.plot(x, f_array) # parabola plt.plot(x, x) # diagonal plt.plot(x, zero_array) # x axes plt.plot(zero_array, x) # y axes for n in range(0, len(x_array) - 1): plt.vlines(x_array[n], x_array[n], x_array[n + 1], "b") plt.hlines(x_array[n + 1], x_array[n], x_array[n + 1], "b") plt.grid() plt.show() plot_itter_diag(x_array, _lambda)
def update_for_slider(val): lambd_local = lambd_slider.val the_plot.set_ydata(stf.iterate(lambd_local, stf.logistic_map, k, delta, x0)) fig.canvas.draw_idle()