Skip to content

Instantly share code, notes, and snippets.

@anddam
Last active March 9, 2017 10:19
Show Gist options
  • Save anddam/1da4db4ae5aec7d881d9f6044ea97170 to your computer and use it in GitHub Desktop.
Save anddam/1da4db4ae5aec7d881d9f6044ea97170 to your computer and use it in GitHub Desktop.
# All comprehension approach
data = {percentage: [multiple_toss(times=times,
steps=step,
percentage=percentage,
factor=factor,
balance=balance
)
for step in range(step_limit)
]
for percentage in percentages
}
# All explicit loops approach
data = {}
for percentage in percentages:
column = []
for step in range(step_limit):
column.append(multiple_toss(times=times,
steps=step,
percentage=percentage,
factor=factor,
balance=balance
))
data[percentage] = column
# Hybrid approach
data = {}
for percentage in percentages:
data[percentage] = [multiple_toss(times=simulations_number,
steps=step,
percentage=percentage,
)
for step in range(step_limit)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment