Случайная выборка из асимметричного распределения фон Мизеса с использованием scipy.stats.rv_continuous - PullRequest
0 голосов
/ 25 октября 2019

Я хочу сделать случайную выборку из асинхронного распределения фон Мизеса.
scipy.stats.vonmises
Синусоидального фон Мизеса : (1 + лямбда* sin (data-mu)) * (распределение по фонам)

Я попытался создать пользовательский дистрибутив с помощью scipy.stats.rv_continuous.
Однако я не могу понять, как исправить ошибку.
В чем плохой смысл моего кода?
Буду признателен, если вы поможете мне с этим.
Заранее спасибо.

Ниже приведен мой код.

import numpy as np
import scipy.special as sc
from scipy import stats    

class skewvonmises_gen(stats.rv_continuous):
    def _pdf(self, x, mu, kappa, skewness):
        return (1 + skewness * np.sin(x-mu)) * (np.exp(kappa * np.cos(x-mu)) / (2*np.pi*sc.i0(kappa)))
    def _argcheck(self, mu, kappa, skewness):
        return (-np.pi <= mu <= np.pi) & (kappa > 0) & (-1 <= skewness <= 1)

skewvonmises = skewvonmises_gen(name="skewvonmises")
skewvonmises.rvs(mu=0, kappa=1, skewness=0, size=1)

Это возвращает следующую ошибку.

C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py:1686: IntegrationWarning: The integral is probably divergent, or slowly convergent.
  return integrate.quad(self._pdf, _a, x, args=args)[0]
C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py:1686: IntegrationWarning: The maximum number of subdivisions (50) has been achieved.
  If increasing the limit yields no improvement it is advised to analyze 
  the integrand in order to determine the difficulties.  If the position of a 
  local difficulty can be determined (singularity, discontinuity) one will 
  probably gain from splitting up the interval and calling the integrator 
  on the subranges.  Perhaps a special-purpose integrator should be used.
  return integrate.quad(self._pdf, _a, x, args=args)[0]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...