import matplotlib.pyplot as plt import numpy as np import random def program1(Nx,Ny, Niters = 100): (x,y) = ( int(Nx/2), int(Ny/2) ) # start in the middle of the box plt.xlim(0,Nx-1) plt.ylim(0,Ny-1) for i in range(Niters): r = random.randint(0,3) if r == 0: x = (x+1)%Nx elif r == 1: x = (x+Nx-1)%Nx elif r == 2: y = (y+1)%Ny elif r == 3: y = (y+Ny-1)%Ny plt.plot(x,y,'ro') # plot the point... plt.pause(0.005) # wait so we can see the point... plt.plot(x,y,'wo') # erase the point The python coding above is a random walk simulator of a particle in 2 dimension. Modifying the simulator to handle N particles instead of one particle. Then, initializing the particles’ positions randomly. After that, extending the random walk simulator so that if two particles are next to each other, they will both freeze, and stop moving. If one of the remaining moving particles winds up next to one of the frozen particles, it should also freeze in place and stop moving.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

import matplotlib.pyplot as plt
import numpy as np
import random

def program1(Nx,Ny, Niters = 100):
(x,y) = ( int(Nx/2), int(Ny/2) ) # start in the middle of the box
plt.xlim(0,Nx-1)
plt.ylim(0,Ny-1)
for i in range(Niters):
r = random.randint(0,3)
if r == 0:
x = (x+1)%Nx
elif r == 1:
x = (x+Nx-1)%Nx
elif r == 2:
y = (y+1)%Ny
elif r == 3:
y = (y+Ny-1)%Ny
plt.plot(x,y,'ro') # plot the point...
plt.pause(0.005) # wait so we can see the point...
plt.plot(x,y,'wo') # erase the point

The python coding above is a random walk simulator of a particle in 2 dimension. Modifying the simulator to handle N particles instead of one particle. Then, initializing the particles’ positions randomly. After that, extending the random walk simulator so that if two particles are next to each other, they will both freeze, and stop moving. If one of the remaining moving particles winds up next to one of the frozen particles, it should also freeze in place and stop moving.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY