Hello, I’m a student majoring biology in Japan.

I am very new to statistics and python so this might be too basic question…

I am trying to fit my experimental data(~200,000 angles, 0~+360, maybe mu=0(360) and 180, bimodal) with mixture of von mises distribution.

I want to predict the parameters(mu, kappa) and the number of components.

I can’t figure out how to git rid of bad initial energy.

**Is this caused by inappropriate prior distibutions?**

I appreciate if you can help me how to go about this.

Thank you in advance.

The following is my code.

```
import pymc3 as pm
import pymc3.distributions.transforms as tr
with pm.Model() as model:
# Use non informative distribution as prior
mu_1 = pm.Uniform('mu_1', 0, 360)
kappa_1 = pm.Uniform('kappa', 0, 10)
mu_2 = pm.Uniform('mu_2', 0, 360)
kappa_2 = pm.Uniform('kappa_2', 0, 10)
component = pm.VonMises.dist(mu=mu_1, kappa=kappa_1)
component1 = pm.VonMises.dist(mu=mu_2, kappa=kappa_2)
# weight of each distribution?
w = pm.Dirichlet('w', np.ones_like([1, 1]), shape=2)
vm = pm.Mixture('vm', w=w, comp_dists=[component, component1],
transform=tr.circular, observed=mydata)
print(model.check_test_point())
with model:
trace = pm.sample(5000, tune=2500, init='adapt_diag')
```

I get following return.

```
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
mu_1_interval__ -1.39
kappa_interval__ -1.39
mu_2_interval__ -1.39
kappa_2_interval__ -1.39
w_stickbreaking__ -1.39
vm NaN
Name: Log-probability of test_point, dtype: float64
Sequential sampling (2 chains in 1 job)
NUTS: [w, kappa_2, mu_2, kappa, mu_1]
0%| | 0/7500 [00:00<?, ?it/s]
SamplingError: Bad initial energy
```

From the other questions, I’m thinking that

```
vm NaN
```

is my problem.