Skip to content

Instantly share code, notes, and snippets.

@mokemokechicken
Last active July 11, 2017 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mokemokechicken/645954e7af05e88d54a88d877a7e389e to your computer and use it in GitHub Desktop.
Save mokemokechicken/645954e7af05e88d54a88d877a7e389e to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
import numpy as np
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
from IPython.core.display import display
%matplotlib inline
N = 10
M = 10
def transfer_money(moneys):
to_moneys = np.random.randint(0, N, N)
for i in range(N):
if moneys[i] > 0:
moneys[i] -= 1
moneys[to_moneys[i]] += 1
moneys = np.ones((N, )) * M
for i in range(10001):
if i % 1000 == 0:
ax = sns.distplot(moneys, kde=False, bins=20)
ax.set_title("i=%d" % i)
ax.set_xlabel("money")
ax.set_ylabel("person count")
plt.show()
transfer_money(moneys)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment