Jump to content

File:BatesCDF.svg

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Original file (SVG file, nominally 720 × 540 pixels, file size: 918 KB)

Summary

Description
English: PDF of Bates Distribution. a = 0, b = 1.
Date
Source Own work
Author Shiyu Ji

Python Source Code

# CDF of Bates Distribution

import matplotlib.pyplot as pl
import numpy as np
import matplotlib.patches as mpatches
import scipy.integrate as integral

t0 = 0.0
dt = 0.001
t_final = 1.0
T = np.arange(t0, t_final, dt)
ax = pl.figure().add_subplot(111)

def factorial(n):
    res = 1
    for i in range(1, n+1):
        res *= i
    return res

def comb(n, k):
    assert (n>=k)
    return factorial(n)/factorial(k)/factorial(n-k)

def F(x, n):
    sum = 0
    k = 0
    while k <= n*x:
        term = comb(n, k)*((n*x-k)**n)
        if k%2==1:
            sum -= term
        else:
            sum += term
        k += 1
    return sum/factorial(n)

def cdf(ax, n, color):
    for t in T:
        old_value = F(t, n)
        new_value = F(t+dt, n)
        ax.plot([t, t+dt], [old_value, new_value], color, linewidth=1.0)

ax.set_ylim([0, 1])
cdf(ax, 1, 'm-')
cdf(ax, 2, 'k-')
cdf(ax, 3, 'b-')
cdf(ax, 10, 'g-')
cdf(ax, 20, 'r-')

magentaPatch = mpatches.Patch(color='magenta', label='$n=1$')
blackPatch = mpatches.Patch(color='black', label='$n=2$')
bluePatch = mpatches.Patch(color='blue', label='$n=3$')
greenPatch = mpatches.Patch(color='green', label='$n=10$')
redPatch = mpatches.Patch(color='red', label='$n=20$')
pl.legend(handles = [magentaPatch, blackPatch, bluePatch, greenPatch, redPatch], loc=2)

pl.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.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

28 May 2017

image/svg+xml

e9660cc8887a412fdd3d946399bb404c9666ff73

940,344 byte

540 pixel

720 pixel

File history

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

Date/TimeThumbnailDimensionsUserComment
current11:48, 28 May 2017Thumbnail for version as of 11:48, 28 May 2017720 × 540 (918 KB)Shiyu JiUser created page with UploadWizard

The following page uses this file:

Global file usage

The following other wikis use this file:

Metadata