Skip to content

Instantly share code, notes, and snippets.

@NickWoodhams
Last active February 1, 2017 22:01
Show Gist options
  • Select an option

  • Save NickWoodhams/f1bb126b95b6f9931e621d8650ea62f3 to your computer and use it in GitHub Desktop.

Select an option

Save NickWoodhams/f1bb126b95b6f9931e621d8650ea62f3 to your computer and use it in GitHub Desktop.

Revisions

  1. NickWoodhams revised this gist Feb 1, 2017. 1 changed file with 32 additions and 0 deletions.
    32 changes: 32 additions & 0 deletions random_matrix.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #! /usr/bin/python

    # required library to create a matrix
    import numpy

    # random int library
    from random import randint

    from pprint import pprint

    # create an empty list variable to add lists into
    rows = []

    # iterate 2000 times, varible i is the number of iteration it's currently on
    for i in range(2000):

    # create 2 random ints between 0 and 1000
    r1 = randint(0, 1000)
    r2 = randint(0, 1000)

    # create a list of the two random ints
    rand_pair = [r1, r2]

    # prints the rand_pair variable to your terminal
    print(rand_pair)

    # append a 1x2 list to the rows list
    rows.append(rand_pair)

    # Creates a numpy matrix
    m = numpy.matrix(rows)
    pprint(m)
  2. NickWoodhams created this gist Feb 1, 2017.
    7 changes: 7 additions & 0 deletions random_pair.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #! /usr/bin/python

    from random import randint

    r1 = randint(0, 1000)
    r2 = randint(0, 1000)
    print(r1, r2)