# Pystan -Initilization failed-

**URL:** <https://discourse.mc-stan.org/t/pystan-initilization-failed/16615>\
**Category:** Modeling\
**Tags:** pystan\
**Created:** [July 15, 2020, 5:40am UTC](https://discourse.mc-stan.org/t/pystan-initilization-failed/16615 "2020-07-15T05:40:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sophist333](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Sophist333](https://discourse.mc-stan.org/u/Sophist333)\
**Post date:** [July 15, 2020, 5:40am UTC](https://discourse.mc-stan.org/t/pystan-initilization-failed/16615/1 "2020-07-15T05:40:01Z")

</div>

Hello everyone.

I’m a begginer of pystan, so I can’t understand why this error has happened.  
Please help me. I used Python in Google Colab.

```stan
# sample.stan
data {
  int<lower = 1> C1;
  int<lower = 1> C2;
  int<lower = 1> C3;
  int<lower = 1> C4;
  int<lower = 1> C5;
}

transformed data{
  int Count[5];
  Count[1] = C1;
  Count[2] = C2;
  Count[3] = C3;
  Count[4] = C4;
  Count[5] = C5;
}

parameters{
  real<lower=0,upper=1> p1;
  real<lower=0,upper=1> p2;
  real<lower=0,upper=1> p3;
  real<lower=0,upper=1> p4;
  real<lower=0,upper=1> p5;
}

transformed parameters{
  vector[5] p;
  p[1] = p1;
  p[2] = p2;
  p[3] = p3;
  p[4] = p4;
  p[5] = p5;
}

model{
  p1 ~ uniform(0,1);
  p2 ~ uniform(0,1);
  p3 ~ uniform(0,1);
  p4 ~ uniform(0,1);
  p5 ~ uniform(0,1);

  Count ~ multinomial(p);
}

```

```python
# python
import pystan

stan_data = {'C1':36, 'C2':47, 'C3':37, 'C4':45, 'C5':40}

sm = pystan.StanModel(file='sample.stan')
fit = sm.sampling(data=stan_data,n_jobs=1)

---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-7-68dcd40d8b15> in <module>()
----> 1 fit = sm.sampling(data=stan_data,n_jobs=1)

1 frames
/usr/local/lib/python3.6/dist-packages/pystan/model.py in sampling(self, data, pars, chains, iter, warmup, thin, seed, init, sample_file, diagnostic_file, verbose, algorithm, control, n_jobs, **kwargs)
    811 call_sampler_args = izip(itertools.repeat(data), args_list, itertools.repeat(pars))
    812 call_sampler_star = self.module._call_sampler_star
--> 813 ret_and_samples = _map_parallel(call_sampler_star, call_sampler_args, n_jobs)
    814 samples = [smpl for _, smpl in ret_and_samples]
    815 

/usr/local/lib/python3.6/dist-packages/pystan/model.py in _map_parallel(function, args, n_jobs)
     88 pool.join()
     89 else:
---> 90 map_result = list(map(function, args))
     91 return map_result
     92 

stanfit4anon_model_531be191e7a7ea491d3706e6921b03ba_1149686610379806072.pyx in stanfit4anon_model_531be191e7a7ea491d3706e6921b03ba_1149686610379806072._call_sampler_star()

stanfit4anon_model_531be191e7a7ea491d3706e6921b03ba_1149686610379806072.pyx in stanfit4anon_model_531be191e7a7ea491d3706e6921b03ba_1149686610379806072._call_sampler()

RuntimeError: Initialization failed.

```

---

<div class="post-metadata">

**Author:** ![nhuurre](https://avatars.discourse-cdn.com/v4/letter/n/ad7895/32.png) [@nhuurre](https://discourse.mc-stan.org/u/nhuurre)\
**Post date:** [July 15, 2020, 6:42am UTC](https://discourse.mc-stan.org/t/pystan-initilization-failed/16615/2 "2020-07-15T06:42:45Z")

</div>

```stan
data {
  int<lower = 1> C1;
  int<lower = 1> C2;
  int<lower = 1> C3;
  int<lower = 1> C4;
  int<lower = 1> C5;
}

transformed data{
  int Count[5] = {C1, C2, C3, C4, C5};
}

parameters{
  simplex[5] p;
}
model{
  p ~ dirichlet([1,1,1,1,1]');
  Count ~ multinomial(p);
}

```

---

<div class="post-metadata">

**Author:** ![Sophist333](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Sophist333](https://discourse.mc-stan.org/u/Sophist333)\
**Post date:** [July 15, 2020, 7:07am UTC](https://discourse.mc-stan.org/t/pystan-initilization-failed/16615/3 "2020-07-15T07:07:47Z")

</div>

Thank you very much! It went well.
