File:Logistic map in the chaotic regime.webm

This is a file from the Wikimedia Commons
From English Wikipedia @ Freddythechick
The media handler extension for this file format is missing. Advanced media features may not work unless the file is viewed at Wikimedia Commons.

Original file(file size: 385 KB, MIME type: video/webm)

Summary

Description
English: Desc

Matplotlib code

import numpy as np
import matplotlib.pyplot as plt

def logistic_map(x, r):
    return r * x * (1 - x)

def function_iter(f, n, x, **kwargs):
    for _ in range(n):
        x = f(x, **kwargs)
    return x

import imageio.v3 as iio
import os
from natsort import natsorted
import moviepy.editor as mp

def export_to_video(dir_paths, fps=12):
    for dir_path in dir_paths:
        file_names = natsorted((fn for fn in os.listdir(dir_path) if fn.endswith('.png')))

        # Create a list of image files and set the frame rate
        images = []

        # Iterate over the file names and append the images to the list
        for file_name in file_names:
            file_path = os.path.join(dir_path, file_name)
            images.append(iio.imread(file_path))

        filename = dir_path[2:]
        iio.imwrite(f"{filename}.gif", images, duration=1000/fps, rewind=True)
        clip = mp.ImageSequenceClip(images, fps=fps)
        clip.write_videofile(f"{filename}.mp4")
    return

from tqdm import tqdm
import os
r = 1 + np.sqrt(8)
x_mid = 0.4
frames=24 * 6

x_maxs = x_mid + np.exp(np.linspace(0, -5, frames)) * 0.4
x_mins = x_mid - np.exp(np.linspace(0, -5, frames)) * 0.4
for i in range(frames):
    x_min = x_mins[i]
    x_max = x_maxs[i]
    fig, ax = plt.subplots(figsize=(30, 5))

    x_values = np.linspace(x_min, x_max, 10000)
    y_values = x_values

    y_values = function_iter(logistic_map,300, y_values, r=r)
    ax.plot(x_values, y_values, alpha=0.2, color='red')
    ax.set_xlim(x_min, x_max)

    dir_path = "./logistic_2"
    if not os.path.exists(dir_path):
        os.makedirs(dir_path)

    fig.savefig(f"{dir_path}/{i}.png")
    plt.close()

export_to_video(["./logistic_2"], fps=12)

Date
Source Own work
Author Cosmia Nebula

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Captions

Add a one-line explanation of what this file represents

6 April 2024

video/webm

394,363 byte

11.52 second

500 pixel

3,000 pixel

ec98a87229e881841a2628c2c5fac4fab2052260

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current02:04, 7 April 2024Thumbnail for version as of 02:04, 7 April 2024 (385 KB)wikimediacommons>Cosmia NebulaUploaded own work with UploadWizard

The following page uses this file: