pytrax/__RandomWalk__.py
def _run_walk(self, walkers):
        r'''
        Run the walk in self contained way to enable parallel processing for
        batches of walkers
        '''
        # Number of walkers in this batch
        nw = len(walkers)
        walkers = np.asarray(walkers)
        wr = walkers.copy()
        # Array to keep track of whether the walker is travelling in a real
        # or reflected image in each axis
        real = np.ones_like(walkers)
#        real_coords = np.ndarray([self.nt, nw, self.dim], dtype=int)
        real_coords = []
        for t in range(self.nt):
            # Random velocity update
            # Randomly select an axis to move along for each walker
            if self.seed:
                np.random.seed(self.seeds[t])
            ax = np.random.randint(0, self.dim, nw)
            # Randomly select a direction positive = 1, negative = 0 index
            if self.seed:
                np.random.seed(self.seeds[-t])
            pn = np.random.randint(0, 2, nw)
            # Get the movement
            m = self.moves[ax, pn]
            # Reflected velocity (if edge is hit)
            m, mr, real = self.check_edge(walkers, ax, m, real)
            # Check for wall hits and zero both movements
            # Cancel moves that hit walls - effectively walker travels half way
            # across, hits a wall, bounces back and results in net zero move
            wall_hit = self.check_wall(walkers, m)
            if np.any(wall_hit):
                m[wall_hit] = 0
                mr[wall_hit] = 0
            # Reflected velocity in real direction
            wr += mr*real
            walkers += m
            if t % self.stride == 0:
                real_coords.append(wr.copy())
        return real_coords
r'''
        Run the walk in self contained way to enable parallel processing for
        batches of walkers
        
r'''
Run the walk in self contained way to enable parallel processing for
batches of walkers
r ' ' ' Run the walk in self contained way to enable parallel processing for batches of walkers
def _run_walk(self, walkers):
        nw = len(walkers)
        walkers = np.asarray(walkers)
        wr = walkers.copy()
        real = np.ones_like(walkers)
        real_coords = []
        for t in range(self.nt):
            if self.seed:
                np.random.seed(self.seeds[t])
            ax = np.random.randint(0, self.dim, nw)
            if self.seed:
                np.random.seed(self.seeds[-t])
            pn = np.random.randint(0, 2, nw)
            m = self.moves[ax, pn]
            m, mr, real = self.check_edge(walkers, ax, m, real)
            wall_hit = self.check_wall(walkers, m)
            if np.any(wall_hit):
                m[wall_hit] = 0
                mr[wall_hit] = 0
            wr += mr*real
            walkers += m
            if t % self.stride == 0:
                real_coords.append(wr.copy())
        return real_coords
def _run_walk ( self , walkers ) : nw = len ( walkers ) walkers = np . asarray ( walkers ) wr = walkers . copy ( ) real = np . ones_like ( walkers ) real_coords = [ ] for t in range ( self . nt ) : if self . seed : np . random . seed ( self . seeds [ t ] ) ax = np . random . randint ( 0 , self . dim , nw ) if self . seed : np . random . seed ( self . seeds [ - t ] ) pn = np . random . randint ( 0 , 2 , nw ) m = self . moves [ ax , pn ] m , mr , real = self . check_edge ( walkers , ax , m , real ) wall_hit = self . check_wall ( walkers , m ) if np . any ( wall_hit ) : m [ wall_hit ] = 0 mr [ wall_hit ] = 0 wr += mr * real walkers += m if t % self . stride == 0 : real_coords . append ( wr . copy ( ) ) return real_coords
r'''
Run the walk in self contained way to enable parallel processing for
batches of walkers
r ' ' ' Run the walk in self contained way to enable parallel processing for batches of walkers
r'''
        Run the walk in self contained way to enable parallel processing for
        batches of walkers
        ''' # Number of walkers in this batch # Array to keep track of whether the walker is travelling in a real # or reflected image in each axis #        real_coords = np.ndarray([self.nt, nw, self.dim], dtype=int) # Random velocity update # Randomly select an axis to move along for each walker # Randomly select a direction positive = 1, negative = 0 index # Get the movement # Reflected velocity (if edge is hit) # Check for wall hits and zero both movements # Cancel moves that hit walls - effectively walker travels half way # across, hits a wall, bounces back and results in net zero move # Reflected velocity in real direction
self
walkers