File:Varianz.gif
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Varianz.gif (300 × 300 pixels, file size: 135 KB, MIME type: image/gif, looped, 48 frames, 14 s)
File information
Structured data
Captions
Summary[edit]
DescriptionVarianz.gif |
English: Animated scatter diagram with two normal distributions with different covariances from -1 to +1.
Deutsch: Animiertes Streudiagramm mit zwei Normalverteilungen mit verschiedenen Kovarianzen von -1 bis +1. |
Date | |
Source | Own work |
Author | Physikinger |
GIF development InfoField | This plot was created with Matplotlib. |
Source code InfoField | Python code# This source code is public domain
import numpy
import matplotlib.pyplot as plt
import imageio
sigma = 5
N = 500
nFrames = 50
numpy.random.seed(0)
d1 = numpy.random.randn(N) * sigma
d2 = numpy.random.randn(N) * sigma
images = []
duration = []
blend = 0.998
for c in numpy.linspace(-1,1,nFrames//2).tolist() + numpy.linspace(-1,1,nFrames//2).tolist()[::-1][1:-1]:
d1 = d1 * blend + numpy.sqrt(1-blend**2) * numpy.random.randn(N) * sigma
d2 = d2 * blend + numpy.sqrt(1-blend**2) * numpy.random.randn(N) * sigma
zero = abs(c) < 1E-4
if c == -1: duration.append(2)
elif zero: duration.append(1.0)
elif c == 1: duration.append(2)
else: duration.append(0.175)
cMat = numpy.array([[1,c],[c,1]]) / numpy.sqrt(1+c**2)
x,y = cMat @ [d1, d2]
fig = plt.figure(figsize=(3.0,3.0), dpi=100)
plt.plot(x,y,'.')
plt.text(0.25, 0.89, ('cov=%'+('' if zero else '+')+'i')%(c*sigma**2), transform=plt.gca().transAxes, fontsize=20)
plt.text(0.32, 0.03, '$\sigma_x$=%0.1f'%sigma, transform=plt.gca().transAxes, fontsize=20)
plt.text(0.03, 0.35, '$\sigma_y$=%0.1f'%sigma, transform=plt.gca().transAxes, rotation=90, fontsize=20)
plt.xlabel('x', labelpad=1)
plt.ylabel('y', labelpad=0)
plt.xlim(-20,20)
plt.ylim(-20,20)
fig.subplots_adjust(
top=0.95,
bottom=0.14,
left=0.18,
right=0.95,
hspace=0.2,
wspace=0.2
)
plt.xlim(-20,20)
plt.ylim(-20,20)
fig.canvas.draw()
s, (width, height) = fig.canvas.print_to_buffer()
images.append(numpy.array(list(s), numpy.uint8).reshape((height, width, 4)))
fig.clf()
plt.close('all')
# Save GIF animation
fileOut = 'Varianz.gif'
imageio.mimsave(fileOut, images, duration=duration)
# Optimize GIF size
# from pygifsicle import optimize
# optimize(fileOut, colors=6)
|
Licensing[edit]
I, the copyright holder of this work, hereby publish it under the following license:
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.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 00:05, 10 March 2022 | 300 × 300 (135 KB) | Physikinger (talk | contribs) | Slower | |
23:59, 9 March 2022 | 300 × 300 (135 KB) | Physikinger (talk | contribs) | More random | ||
23:43, 9 March 2022 | 300 × 300 (134 KB) | Physikinger (talk | contribs) | Correct variance | ||
23:23, 9 March 2022 | 300 × 300 (133 KB) | Physikinger (talk | contribs) | Uploaded own work with UploadWizard |
You cannot overwrite this file.
File usage on Commons
There are no pages that use this file.
File usage on other wikis
The following other wikis use this file:
- Usage on be.wikipedia.org
- Usage on de.wikipedia.org