Hello! I am using your package to sample quaternions in non isotropic distributions, in particular Kent distribution.
I would like to suggest a small addition to make sampling from seeded generators easier by changing the class method rvs(self, n_samples=None)
to rvs(self, n_samples=None,random_gen=None)
by adding the possibility to pass a Numpy generator as argument like the model of the rvs_continuous class of scipy.stats.
For instance, if using scipy.stats
:
def _rvs_helper(self,random_gen=None):
num_samples = 10000
xs = gauss(0, 1).rvs((num_samples, 3),random_state=random_gen)
xs = np.divide(xs, np.reshape(norm(xs, 1), (num_samples, 1)))
lpvalues = self.log_pdf(xs, normalize=False)
lfmax = self.log_pdf_max(normalize=False)
shifted = lpvalues - lfmax
return xs[uniform(0, 1).rvs(num_samples,random_state=random_gen) < np.exp(shifted)]
Where random_state
is eitheir a None
, int
or numpy.random.generator .
another possibility if using numpy.random
from numpy.random import default_gen
# [...]
def _rvs_helper(self,random_gen=None):
num_samples = 10000
if random_gen is None:
random_gen = default_gen()
xs = random_gen.normal(0, 1,(num_samples,3))
xs = np.divide(xs, np.reshape(norm(xs, 1), (num_samples, 1)))
lpvalues = self.log_pdf(xs, normalize=False)
lfmax = self.log_pdf_max(normalize=False)
shifted = lpvalues - lfmax
return xs[random_gen.uniform(0, 1, num_samples) < np.exp(shift)]
Thank you for your package !