i have this code :
class random_walk:
#ns: number of steps1d
#np: number of particles
#dimension : choose between 1D or 2D
def __init__(self,ns,np,dimension=None):
self.ns=ns
self.np=np
self.dimension=dimension
def steps1d(self,ns):
return 2*sc.random.random_integers(0,1,size=self.ns)-1
# The position of particles after the n-th steps1d is given from the sum of n first steps1d
def Walk1d(self,ns):
return sc.cumsum(random_walk.steps1d(self,self.ns)
.....
When i do :
ns=10000
np=100
dimension=2
rw1=random_walk(ns,np) # for 1d
the rw1 creates an instance for the class random_walks,which has ns=10000.
Now,if for example i want to do :
print('walk1d(10)=',rw1.Walk1d(10))
it will give me 10000 size array (because if i am telling this right ,it created an instance before with 10000 ns).
So, if i want to apply the above statement in order to give me 10 size array what solutions exists?
1 Answer