From 2b865e4c02c1f03c8201e77309a7a5b157e3abaa Mon Sep 17 00:00:00 2001 From: Wesley Kuhron Jones Date: Fri, 28 Oct 2022 17:08:50 +0000 Subject: [PATCH] fix typo with greater/less than --- Chaos/CombinedStrangeAttractors.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Chaos/CombinedStrangeAttractors.py b/Chaos/CombinedStrangeAttractors.py index b5b562cb..db7eae36 100644 --- a/Chaos/CombinedStrangeAttractors.py +++ b/Chaos/CombinedStrangeAttractors.py @@ -39,7 +39,7 @@ def converges_with_complexity(self): total_unique_ratio = total_unique_points / total_points return False, total_unique_points, total_points, total_unique_ratio - def get_convergence_points(self, x_min=-1, x_max=1, y_min=-1, y_max=1, resolution=100, max_iterations=10000, max_abs=1e6): + def get_convergence_points(self, x_min=-1, x_max=1, y_min=-1, y_max=1, resolution=100, max_iterations=10000, max_abs=100): print("getting convergence array") xs = np.linspace(x_min, x_max, resolution) ys = np.linspace(y_min, y_max, resolution) @@ -56,7 +56,7 @@ def get_convergence_points(self, x_min=-1, x_max=1, y_min=-1, y_max=1, resolutio print("done getting convergence array") return convergence - def plot_convergence_points(self, x_min=-1, x_max=1, y_min=-1, y_max=1, resolution=100, max_iterations=10000, max_abs=1e6): + def plot_convergence_points(self, x_min=-1, x_max=1, y_min=-1, y_max=1, resolution=100, max_iterations=10000, max_abs=100): convergence_array = self.get_convergence_points(x_min, x_max, y_min, y_max, resolution, max_iterations, max_abs) plt.imshow(convergence_array) plt.colorbar() @@ -77,7 +77,7 @@ def find_convergent_initial_condition(self, min_index, max_index): x0 = r * np.cos(theta) y0 = r * np.sin(theta) # x0, y0 = np.random.uniform(-1, 1, (2,)) - trajectory = get_late_trajectory(self, x0, y0, min_index=min_index, max_index=max_index, max_abs=1e6) + trajectory = get_late_trajectory(self, x0, y0, min_index=min_index, max_index=max_index, max_abs=100) if trajectory_diverges(trajectory): continue else: @@ -199,11 +199,10 @@ def __repr__(self): return f"" -def get_late_trajectory(mapping, x0, y0, min_index, max_index, max_abs=1e9): +def get_late_trajectory(mapping, x0, y0, min_index, max_index, max_abs=100): assert max_index > min_index res = [] x,y = x0,y0 - BIG = max_abs # if it gets to this distance then assume it diverges for i in range(max_index): x,y = mapping(x,y) if i < min_index: @@ -211,9 +210,9 @@ def get_late_trajectory(mapping, x0, y0, min_index, max_index, max_abs=1e9): continue else: res.append((x,y)) - if not np.isfinite(x) or not np.isfinite(y) or abs(x) > BIG or abs(y) > BIG: - # assume it will diverge forever if it ever reaches inf/NaN - # just put a nonfinite pair at the end and return + if not np.isfinite(x) or not np.isfinite(y) or abs(x) > max_abs or abs(y) > max_abs: + # assume it will diverge forever if it ever reaches inf/NaN or max_abs + # just put a nonfinite pair at the end and return without checking later iterations res.append((np.inf, np.inf)) return res return res @@ -303,7 +302,7 @@ def run_mixing_experiment(mapping_names=None): divergence_count = 0 plot_success = False - while not (plot_success or divergence_count < 5): + while not (plot_success or divergence_count > 5): try: mapping.plot_attractor() plot_success = True # this will break while loop @@ -410,7 +409,7 @@ class MappingRecord: # plt.show() run_mixing_experiment() - # run_mixing_experiment(["W", "X"]) + # run_mixing_experiment(["AL", "AS"]) # while True: # run_perturbation_experiment(perturbation_nelda=random.choice([1, 1.5, 2, 2.5, 3])) @@ -429,6 +428,6 @@ class MappingRecord: # - AS + Z (zigzag spiral) # - AS + AK (looks like letters in a curvy script) # - X + W (messy dusty danish) - + # - AS + AL (pentagon made of line bundles)