DEV Community

Durga Pokharel
Durga Pokharel

Posted on

Day 65 Of 100DaysOfCode: Implement Clumsiness

This is my 65th days of #100daysofcode and #python learning. Today learned more about data visualization from matplotlib. Completed some assignment in datacamp.

Implement Clumsiness

# Simulate random walk 250 times
all_walks = []
for i in range(10) :
    random_walk = [0]
    for x in range(100) :
        step = random_walk[-1]
        dice = np.random.randint(1,7)
        if dice <= 2:
            step = max(0, step - 1)
        elif dice <= 5:
            step = step + 1
        else:
            step = step + np.random.randint(1,7)

        # Implement clumsiness
        if ___ :
            step = 0

        random_walk.append(step)
    all_walks.append(random_walk)

# Create and plot np_aw_t
np_aw_t = np.transpose(np.array(all_walks))
plt.plot(np_aw_t)
plt.show()
Enter fullscreen mode Exit fullscreen mode

Day 65 Of #100DaysOfCode and #Python3
Worked on data visualization using matplotlib.#WomenInTechnology ,#100DaysOfCode ,#CodeNewbie #DEVCommunity pic.twitter.com/yogjWr5YP9

— Durga Pokharel (@mathdurga) March 3, 2021

Top comments (1)

Collapse
 
mccurcio profile image
Matt Curcio

That's funny. I haven't thought about a "clumsy" random walker before.
If you fell down on your random walker and near the end of your walk, you
would have to jump and fall(at the same time) all the way to the beginning. lol
Quite a feat!