(self, seed=None)
return self.rng
Generate the random number generator on device and on host.

        Arguments:
            seed (int): random number generator seed

        Returns:
            seeded numpy RNG
Generate the random number generator on device and on host.
Generate the random number generator on device and on host .
def gen_rng(self, seed=None):
        """
        Generate the random number generator on device and on host.

        Arguments:
            seed (int): random number generator seed

        Returns:
            seeded numpy RNG
        """
        # generate on host rng
        self.rng = np.random.RandomState(seed)

        # this RNG is for handling normally distributed numbers on device
        self.pcg = rng_mrg()
        # save the initial state of host rng
        self.init_rng_state = self.rng.get_state()

        # generate random integers to seed the LSFR
        # RNGs on the device
        self.init_rng_state_dev = self._gen_dev_randstate()

        # call below is mainly to set on device RNG states
        # to self.init_rng_state_dev
        self.rng_reset()

        # if the current context already has an rng clear it
        ctx = drv.Context.get_current()
        if ctx in self.context_rand_state_alive:
            self.context_rand_state_alive[ctx] = False

        # generate the on device RNG
        self._set_rand_state_dev(state=self.init_rng_state_dev)
        return self.rng
def gen_rng ( self , seed = None ) : # generate on host rng self . rng = np . random . RandomState ( seed ) # this RNG is for handling normally distributed numbers on device self . pcg = rng_mrg ( ) # save the initial state of host rng self . init_rng_state = self . rng . get_state ( ) # generate random integers to seed the LSFR # RNGs on the device self . init_rng_state_dev = self . _gen_dev_randstate ( ) # call below is mainly to set on device RNG states # to self.init_rng_state_dev self . rng_reset ( ) # if the current context already has an rng clear it ctx = drv . Context . get_current ( ) if ctx in self . context_rand_state_alive : self . context_rand_state_alive [ ctx ] = False # generate the on device RNG self . _set_rand_state_dev ( state = self . init_rng_state_dev ) return self . rng