File:Histogram sum of length 3 permutations of 1 2 3.svg

From testwiki
Jump to navigation Jump to search
Original file (SVG file, nominally 576 × 432 pixels, file size: 35 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: Bar graph depicting the probability mass function of X, where X is the sum of 3 discrete random variables uniformly selected from the set {1, 2, 3}.
Date
Source Own work
Author DLohmann

Python code

from itertools import product
from matplotlib import pyplot as plt
import numpy as np

def plot_sums(num_terms):
  l = list(product(np.arange(1, 4), repeat=num_terms))
  sums = list(map(sum, l))
  bins = np.bincount(np.array(sums))
  plt.title("Sums of all possible permutations of 1, 2, 3 of length " + str(num_terms) + " elements")
  plt.xlabel("Sum of permutation")
  plt.ylabel("Number of permutations")
  plt.grid(axis="y",zorder=0)
  plt.locator_params(axis='both', integer=True)
  plt.xlim(0, max(4, bins.argmax()*2))
  plt.bar(np.arange(len(bins)), bins, zorder=2)
  plt.savefig("Histogram sum of length " + str(num_terms) + " permutations of 1 2 3.svg")

plot_sums(1)

plt.clf()
plot_sums(2)

plt.clf()
plot_sums(3)

This was made using Python 3.

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

Sum of all permutations of length 3 selected from the set of integers 1, 2, 3

Items portrayed in this file

depicts

5 January 2020

35,653 byte

image/svg+xml

116ae1099bd87064ef488237bac1cc08953f58da

File history

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

Date/TimeThumbnailDimensionsUserComment
current13:35, 5 January 2020Thumbnail for version as of 13:35, 5 January 2020576 × 432 (35 KB)wikimediacommons>DLohmannUser created page with UploadWizard

The following page uses this file: