This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nodeNameList = [] | |
for i in nodes: | |
nodeName = Node.getName(i) | |
nodeNameList.append(nodeName) | |
print nodeNameList | |
for n in nodeNameList[0]: | |
if nodeNameList[0].index(n) == nodeNameList[1].index(n): | |
connectionLetter = n | |
print connectionLetter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter the code for the functions rabbitGrowth, foxGrowth, and runSimulation | |
# in this box. | |
def rabbitGrowth(): | |
""" | |
rabbitGrowth is called once at the beginning of each time step. | |
It makes use of the global variables: CURRENTRABBITPOP and MAXRABBITPOP. | |
The global variable CURRENTRABBITPOP is modified by this procedure. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rabbitGrowth(): | |
global CURRENTRABBITPOP | |
global MAXRABBITPOP | |
num = CURRENTRABBITPOP | |
for i in xrange(num): | |
if random.random() < (1 - (float(CURRENTRABBITPOP) / MAXRABBITPOP)): | |
CURRENTRABBITPOP += 1 | |
def foxGrowth(): | |
global CURRENTRABBITPOP | |
global CURRENTFOXPOP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rabbitGrowth(): | |
""" | |
rabbitGrowth is called once at the beginning of each time step. | |
It makes use of the global variables: CURRENTRABBITPOP and MAXRABBITPOP. | |
The global variable CURRENTRABBITPOP is modified by this procedure. | |
For each rabbit, based on the probabilities in the problem set write-up, | |
a new rabbit may be born. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rabbitGrowth(): | |
""" | |
rabbitGrowth is called once at the beginning of each time step. | |
It makes use of the global variables: CURRENTRABBITPOP and MAXRABBITPOP. | |
The global variable CURRENTRABBITPOP is modified by this procedure. | |
For each rabbit, based on the probabilities in the problem set write-up, | |
a new rabbit may be born. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pylab | |
import random | |
def MC(numBalls, numTrials): | |
ballsStudiedList = [] | |
for i in range(numTrials): | |
ballList = [] | |
ballListCopy = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pylab | |
import random | |
def LV(numBalls, numTrials): | |
finalSteps = [] | |
for i in range(numTrials): | |
ballList = [] | |
steps = 0 | |
for i in range(numBalls): | |
i = random.choice(['white', 'black']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 6.00 Problem Set 9 | |
import numpy | |
import random | |
import pylab | |
from ps8b_precompiled_27 import * | |
# | |
# PROBLEM 1 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pylab | |
"""Rows 4 to 13 copied from l15-3.py - available in the lecture.""" | |
#set line width | |
pylab.rcParams['lines.linewidth'] = 6 | |
#set font size for titles | |
pylab.rcParams['axes.titlesize'] = 20 | |
#set font size for labels on axes | |
pylab.rcParams['axes.labelsize'] = 20 | |
#set size of numbers on x-axis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This code will produce "The output of random.randint(1, 10) after a specific seed is shown below." | |
""" | |
import random | |
random.seed(9001) | |
print random.randint(1, 10) | |
print random.randint(1, 10) | |
print random.randint(1, 10) | |
print random.randint(1, 10) | |
print random.randint(1, 10) |
NewerOlder