File:Poisson pmf.svg

From Training Material
Jump to navigation Jump to search

Original file(SVG file, nominally 330 × 255 pixels, file size: 86 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: Plot of the probability mass function for the Poisson distribution.
Date
Source Own work
Author Skbkekas
SVG genesis
InfoField
 
The SVG code is valid.
 
This plot was created with Matplotlib
Source code
InfoField

Python code

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

col = {1 : 'orange', 4: 'purple', 10: 'lightblue'}

X = np.arange(0, 21)

plt.rc('text', usetex = True)
plt.rc('font', family = 'serif', size = 12)

##                                                                                
## PMF                                                                            
## 

plt.clf()
plt.figure(figsize=(4,3.2))

A = []
for L in 1,4,10:

    P = -L + X*np.log(L) - sp.gammaln(X+1)
    P = np.exp(P)

    plt.plot(X, P, '-', color='grey', label='_nolegend_')
    a = plt.plot(X, P, 'o', color=col[L], markeredgecolor='k', markeredgewidth=0.5)
    A.append(a)

plt.xlabel("$k$")
plt.ylabel(r"$P(x=k)$")
plt.ylim([0,0.4])
plt.yticks(np.arange(0,0.42,.05))
plt.tick_params(direction='in', top=True, right=True)

plt.legend((r"$\lambda=1$", r"$\lambda=4$", r"$\lambda=10$"),
                numpoints=1, handlelength=0.75, handletextpad=0.5,\
                loc="upper right", frameon=False)
plt.xlim(-1,21)

plt.savefig("poisson_pmf.pdf")
plt.savefig("poisson_pmf.svg")

Licensing

I, the copyright holder of this work, hereby publish it under the following licence:
w:en:Creative Commons
attribution
This file is licensed under the Creative Commons Attribution 3.0 Unported licence.
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 licence, 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.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

10 February 2010

image/svg+xml

File history

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

Date/TimeThumbnailDimensionsUserComment
current03:26, 21 November 2020Thumbnail for version as of 03:26, 21 November 2020330 × 255 (86 KB)wikimediacommons>AkanoToERemoved white background and recropped to fit axis labels

The following page uses this file:

Metadata