Anar al contingut

Archiu:Donsker theorem for normal distributions.gif

De L'Enciclopèdia, la wikipedia en valencià
Resolució completa. ((2000 × 600 pixels, tamany de l'archiu: 4,5 MB, MIME tipo: image/gif), buclejat, 132 marcos, 11s)
Nota: degut a llimitacions tècniques, les miniatures d'imàgens GIF d'alta resolució com esta no estaran animades.

Est archiu és de Wikimedia Commons i pot usar-se en atres proyectes. La descripció en la seua pàgina de descripció de l'archiu es mostra més avall.

Summary

Description
English: ```python

import numpy as np import matplotlib.pyplot as plt import scipy

import tempfile import os import imageio

  1. generate random samples from

def plot_bridge(samples=None, n=1000, dist=scipy.stats.norm, dist_name="normal", low=-3, high=+3):

   fig, axes = plt.subplot_mosaic("ABB", figsize=(20, 6))
   ax1 = axes["A"]
   ax2 = axes["B"]
   if samples is None:
       samples = dist.rvs(size=n)
   else:
       n = len(samples)
   x = sorted(samples)
   y = dist.cdf(x)
   ref_x = np.linspace(low,high, 1000)
   ref_y = dist.cdf(ref_x)
   # calculate empirical cdf
   ecdf = np.arange(n) / len(samples)
   # plot cdf of standard normal distribution and empirical cdf of samples
   ax1.plot(ref_x, ref_y, label='Standard CDF')
   ax1.plot(x, ecdf, label='Empirical CDF')
   ax1.set_title()
   ax1.set_xlim(low,high)
   ax1.legend()
   ax1.set_ylim(0,1)
   ax2.plot([0.0] + dist.cdf(x)                        .tolist() + [1.0], 
            [0.0] + (np.sqrt(n) * (ecdf - dist.cdf(x))).tolist() + [0.0])
   ax2.set_title('centered, scaled, and re-timed')
   ax2.set_ylim(-0.9, 0.9)
   fig.suptitle(f"{dist_name}, with n = {n}")
   return fig

def interpolate_counts(counts, frames_per_step):

   interpolated_counts = [counts[0]]
   for i in range(1,len(counts)):
       interval = (counts[i] - counts[i-1]) // i
       interpolated_counts += list(range(counts[i-1], counts[i], interval))
   return interpolated_counts + [counts[-1]]

with tempfile.TemporaryDirectory() as temp_dir:

   dist = scipy.stats.norm
   dist_name = "normal"
   low, high = -3.5, +3.5
   
   n_steps = 16
   frames_per_step = 10
   sample_counts = interpolate_counts([2**n for n in range(n_steps)], frames_per_step)
   n_frames = len(sample_counts)-1
   samples = dist.rvs(size=sample_counts[0]).tolist()
   
   for i in range(n_frames):
       samples += dist.rvs(size=sample_counts[i+1]-sample_counts[i]).tolist()
       fig = plot_bridge(samples, dist=dist, dist_name=dist_name, low=low,high=high)
       filename = os.path.join(temp_dir, f"plot_{i:03d}.png")
       fig.savefig(filename)
       plt.close(fig)
   # Compile images into GIF
   fps = 12
   images = []
   for i in range(n_frames):
       filename = os.path.join(temp_dir, f"plot_{i:03d}.png")
       images.append(imageio.imread(filename))
   imageio.mimsave(f"{dist_name} Donsker theorem.gif", images, duration=1/fps)
```
Date
Source Own work
Author Cosmia Nebula

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.

Captions

Add a one-line explanation of what this file represents
Donsker-Skorokhod-Kolmogorov theorem for normal distributions

Items portrayed in this file

depicts English

creator English

Some value without a Wikidata item

copyrighted English

inception English

3 March 2023

media type English

image/gif

data size English

4,721,479 byte

height English

600 pixel

width English

2,000 pixel

checksum English

d9757787562d2d5c01f415ae3f0ab5b1d0c93f56

Historial de l'image

Puncha en la data/hora per a vore l'image tal i com es mostrava en eixe moment.

Data/HoraMiniaturaDimensionsUsuariDescripció
actual06:09 4 març 2023Miniatura de la versió de 06:09 4 març 20232000 × 600 (4,5 MB)wikimediacommons>Cosmia NebulaUploaded own work with UploadWizard

Les següents pàgines enllacen ad esta image: