Giter VIP home page Giter VIP logo

lorenzattractor's Introduction

Chaotic Attractor

This code uses a chaotic attractor (the Lorenz equations) to create variations of any given input sequence (e.g. music, natural language, etc). The variant has the general theme of the original data, however it remixes it slightly to add a funky new twist.

Lorenz Equations

Therefore the heart of this project lies in computing the (chaotic) trajectory of the Lorenz Equations:

def lorenz(x,y,z, sigma=10.0, rho=28.0, beta=8.0/3, dt = 1e-2):
    # the lorenz system exhibits chaotic behaviour     
    # if sigma,rho,beta are set at these values
    xd = sigma * (y - x)
    yd = (rho-z)*x - y
    zd = x*y - beta*z
    # x,y,z derivatives calculated 
    # according to the lorenz equations
    x += xd * dt
    y += yd * dt
    z += zd * dt 
    return x,y,z

Butterfly Effect

This isnt the only chaotic attractor out there, but it is one of the more famous ones. A 3D trajectory of the attractor looks like this: If you restart from the same initial conditions (x,y,z) BUT change one value ever so slightly (by a value of, say, +/- 0.001), then the resulting trajectory (orange) will gradually diverge until it is wildly different from the original (blue)!!! This is called sensitive dependence on initial conditions (or more popularly termed "the butterfly effect")

Sample Results

There are tests provided in the code which demo the applications of this on various types of input data. A midi file (Bach's prelude in C) is hard coded into the file (https://raw.githubusercontent.com/mohammedterry/chaotic-attractor/master/screenshots/bach.mp4) is chaotically remixed by the program to create a musical variant: (https://raw.githubusercontent.com/mohammedterry/chaotic-attractor/master/screenshots/variant1.mp4) (https://raw.githubusercontent.com/mohammedterry/chaotic-attractor/master/screenshots/variant2.mp4)

and a sample text is provided to show this chaotic reordering on natural language (compare the story to the original)

How?

The original input data is stored along the x,y,z coordinates of the orinal trajectory.
The second trajectory will pass by some of the first's trajectory's coordinates, however, not in the exact same order (since its a chaotic variant). The amazing thing is - the trajectory will always differ, since its a chaotic system Inspired by the fabulous online Complexity Explorer Courses offered by Santa Fe Institute (https://www.complexityexplorer.org/courses/79-nonlinear-dynamics-mathematical-and-computational-approaches-fall-2017)

lorenzattractor's People

Contributors

mohammedterryjack avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.