File:Logistic Map Bifurcation Diagram, Matplotlib.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 576 × 432 pixels, file size: 771 KB)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: A bifurcation diagram for the Logistic map:
    xn+1=rxn(1−xn)
    The horizontal axis is the r parameter, the vertical axis is the x variable. A starting value of x=0.25 was used, and the map was iterated 1000 times in order to stabilize the values of x. 1,000,000 x -values were then calculated for each value of r and for each x value, the corresponding (x,r) pixel in the image was incremented by one. All values in a column (corresponding to a particular value of r) were then multiplied by the number of non-zero pixels in that column, in order to even out the intensities. See File:Logistic Map Bifurcation Diagram, Matplotlib, zoomed.png for a vectorized and therefore much faster version of this Python script.
    Date
    Source Own work
    Author Morn
    SVG development
    InfoField
     The SVG code is valid.
     This plot was created with Matplotlib.
    Source code
    InfoField

    Python code

    Source code
    from pylab import *
    from numpy import NaN
    from matplotlib.colors import LogNorm
    
    dr, dx = .001, .001
    max_it = 1000000
    
    R = arange(2.4, 4, dr)
    X = arange(0, 1, dx)
    Z = zeros((len(X), len(R)))
    
    for ir, r in enumerate(R):
    	print (ir, "of", len(R))
    	z = .25
    	for i in range(1000):
    		z = r * z * (1 - z)
    	for i in range(max_it):
    		z = r * z * (1 - z)
    		Z[-int(z / dx), ir] += 1
    	Z[:, ir] *= count_nonzero(Z[:, ir])
    
    Z = where(Z > 0, Z, NaN)
    save("logmap", Z)	# save array to file
    
    # pick color bar range:
    zmi = .005 * nanmax(Z)
    zma = .1   * nanmax(Z)
    
    imshow(Z, cmap = plt.cm.viridis_r, vmin = zmi, vmax = zma,
      interpolation = 'none', norm = LogNorm(),
      extent = (R.min(), R.max(), X.min(), X.max()))
    xlabel("r")
    ylabel("x")
    savefig("Logistic Map Bifurcation Diagram, Matplotlib.svg")
    show()
    

    Licensing

    I, the copyright holder of this work, hereby publish it under the following license:
    w:en:Creative Commons
    attribution share alike
    This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
    You are free:
    • to share – to copy, distribute and transmit the work
    • to remix – to adapt the work
    Under the following conditions:
    • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
    • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
    Annotations
    InfoField
    This image is annotated: View the annotations at Commons

    Captions

    Add a one-line explanation of what this file represents

    Items portrayed in this file

    depicts

    19 January 2019

    File history

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

    Date/TimeThumbnailDimensionsUserComment
    current14:55, 19 January 2019Thumbnail for version as of 14:55, 19 January 2019576 × 432 (771 KB)wikimediacommons>Mornuse a million samples (less noise)

    There are no pages that use this file.