Jump to content

File:Geometric pmf.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 675 × 288 pixels, file size: 52 KB)

Summary

Description
English: Plot of the probability mass functions of several members of the family of geometric distributions.
Date
Source Own work
Author Skbkekas
SVG development
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 = {0.2: 'orange', 0.5: 'purple', 0.8: 'lightblue'}

plt.clf()
plt.figure(figsize=(7.5,3.2))
ax1 = plt.axes([0.08,0.13,0.4,0.8])
ax2 = plt.axes([0.57,0.13,0.4,0.8])
plt.hold(True)

X1 = np.arange(1,11)
X2 = np.arange(0,11)

A1,A2 = [],[]
for p in 0.2,0.5,0.8:
    Y1 = (X1-1)*np.log(1-p) + np.log(p)
    Y1 = np.exp(Y1)
    Y2 = X2*np.log(1-p) + np.log(p)
    Y2 = np.exp(Y2)
    ax1.plot(X1, Y1, '-', color='grey', lw=1)
    ax2.plot(X2, Y2, '-', color='grey', lw=1)
    a1 = ax1.plot(X1, Y1, 'o', color=col[p], lw=3)
    a2 = ax2.plot(X2, Y2, 'o', color=col[p], lw=3)
    A1.append(a1)
    A2.append(a2)

ax1.set_xlabel("x")
ax1.set_ylabel("P(X=x)")
ax2.set_xlabel("x")
ax2.set_ylabel("P(X=x)")

bx1 = ax1.legend(A1, ("p=0.2", "p=0.5", "p=0.8"),\
                 numpoints=1, handletextpad=0, loc="upper right")
bx2 = ax2.legend(A2, ("p=0.2", "p=0.5", "p=0.8"),\
                numpoints=1, handletextpad=0, loc="upper right")
bx1.draw_frame(False)
bx2.draw_frame(False)
ax1.set_xlim(-0.2,10.2)
ax2.set_xlim(-0.2,10.2)
ax1.set_ylim(-0.05,1.05)
ax2.set_ylim(-0.05,1.05)

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

Licensing

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

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

26 February 2010

File history

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

Date/TimeThumbnailDimensionsUserComment
current23:30, 26 February 2010Thumbnail for version as of 23:30, 26 February 2010675 × 288 (52 KB)Skbkekas{{Information |Description={{en|1=Plot of the probability mass functions of several members of the family of geometric distributions.}} |Source={{own}} |Author=Skbkekas |Date=2010-02-26 |Permission= |other_versions= }} [[Category:Statis

Global file usage

The following other wikis use this file: