Example #1
0
    def sample(self, key, sample_shape=()):
        """ Generate sample from von Mises distribution

            :param sample_shape: shape of samples
            :param key: random number generator key
            :return: samples from von Mises
        """
        samples = von_mises_centered(key, self.concentration,
                                     sample_shape + self.shape())
        samples = samples + self.loc  # VM(0, concentration) -> VM(loc,concentration)
        samples = (samples + jnp.pi) % (2. * jnp.pi) - jnp.pi

        return samples
Example #2
0
def test_von_mises_centered(concentration):
    samples = von_mises_centered(random.PRNGKey(0),
                                 concentration,
                                 shape=(10000, ))
    cdf = scipy.stats.vonmises(kappa=concentration).cdf
    assert scipy.stats.kstest(samples, cdf).pvalue > 0.01