File:Logistic Map Bifurcation Diagram, Matplotlib, zoomed.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(3,840 × 2,880 pixels, file size: 7.34 MB, MIME type: image/png)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

Description
English: A bifurcation diagram for the Logistic map (100,000 iterations). The code is a vectorized version of the scalar code at File:Logistic Map Bifurcation Diagram, Matplotlib.svg which runs much faster but also needs more RAM because iteration results are stored in an array. Iterations are done in batches ("cycles") to lessen RAM demands.
Date
Source Own work
Author Morn
PNG development
InfoField
 
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
import time
from sys import getsizeof

dr, dx = .001/4, .001/4

# Perform max_it iterations at a time, repeated over it_cyc cycles.
# (This is done so that the memory requirement for the out array
# does not get too big. Lower max_it if you do not have enough free RAM.)
max_it = 10000
it_cyc = 10

R = arange(3.5, 4, dr)
X = arange(0, 1, dx)
Z = zeros((len(X), len(R)))

z = zeros((len(R)))
out = zeros((max_it, len(R)))
print("out array size is", int(getsizeof(out) / 1024 / 1024), "MB")

start = time.time()

for cy in range(it_cyc):
	z[:] = (cy + .5) / it_cyc	# use different starting values, not just 0.25
	for i in range(1000):
		z[:] = R[:] * z[:] * (1 - z[:])

	print("cycle", cy + 1, "of", it_cyc)
	for i in range(max_it):
		if i and not i % 1000:
			itpers = i / (time.time() - start)
			left = (max_it - i) / itpers
			#print (i, ",", int(left), "s left for iterations")
		z[:] = R[:] * z[:] * (1 - z[:])
		out[i, :] = z[:]

	for ir, r in enumerate(R):
		#print (ir, "of", len(R), "histograms done")
		h = histogram(out[:, ir], bins = list(X))[0]
		Z[1:, ir] += h[::-1]

for ir, r in enumerate(R):
	Z[:, ir] *= count_nonzero(Z[:, ir])

Z = where(Z > 0, Z, NaN)
save("logmap", Z)	# save array to file

# pick color bar range:
zmi = .001 * nanmax(Z)
zma = .1   * nanmax(Z)

imshow(Z, cmap = plt.cm.viridis_r, vmin = zmi, vmax = zma,
  interpolation = 'none', norm = LogNorm(), aspect = "auto",
  extent = (R.min(), R.max(), X.min(), X.max()))
xlabel("r")
ylabel("x")
axis((3.5, 4, 0, 1))
# SVG size is 12 MB and crashes Firefox, so save as PNG instead:
savefig("Logistic Map Bifurcation Diagram, Matplotlib, zoomed.png", dpi = 600)
print("===", max_it * it_cyc, "total iterations")
print("===", int(time.time() - start), "s total time")
show()

Licensing[edit]

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.

File history

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

Date/TimeThumbnailDimensionsUserComment
current19:27, 19 January 2019Thumbnail for version as of 19:27, 19 January 20193,840 × 2,880 (7.34 MB)Morn (talk | contribs)use different starting values (looks more smooth)
18:06, 19 January 2019Thumbnail for version as of 18:06, 19 January 20193,840 × 2,880 (5.87 MB)Morn (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file:

Metadata