Gausian Mixture Model takes too long to sample

I am pretty new to Gaussian Mixture Modeling. I am following a few tutorials and all of them take a lot of time to fit.

The first one is the most intuitive one

``````import pymc as pm
import numpy as np
import matplotlib.pyplot as plt

## Generate data with K components.
# Means, standard deviations, proportions
mus = [ 0, 6,-5]
sigmas = [ 1, 1.5, 3]
ps = [.2, .5,.3]

# Total amount of data
N = 1000

# Stack data into a single array
data = np.hstack([np.random.normal(mus[0], sigmas[0], int(ps[0]*N)),
np.random.normal(mus[1], sigmas[1], int(ps[1]*N)),
np.random.normal(mus[2], sigmas[2], int(ps[2]*N))])

## Build model
gmm = pm.Model()
# Specify number of groups
K = 3

with gmm:
# Prior over z
p = pm.Dirichlet('p', a=np.array([1.]*K))
# z is the component that the data point is being sampled from.
# Since we have N data points, z should be a vector with N elements.
z = pm.Categorical('z', p=p, shape=N)

# Prior over the component means and standard deviations
mu = pm.Normal('mu', mu=0., sigma=10., shape=K)
sigma = pm.HalfCauchy('sigma', beta=1., shape=K)

# Specify the likelihood
Y_obs = pm.Normal('Y_obs', mu=mu[z], sigma=sigma[z], observed=data)
trace = pm.sample()
``````

and the second one is from the Mixture Docs of PyMC,

``````n_components = 3
with pm.Model() as gauss_mix:
mu = pm.Normal("mu", mu=data.mean(),
sigma=10,
shape=n_components,
transform=pm.distributions.transforms.univariate_ordered,
initval=[1, 2, 3],
)
sigma = pm.HalfNormal("sigma", sigma=10, shape=n_components)
weights = pm.Dirichlet("w", np.ones(n_components))

y_ = pm.NormalMixture("y_", w=weights, mu=mu, sigma=sigma, observed=data)
trace = pm.sample()
``````

What is going on here? I was reading about reparametrizations, but only in the case of Multivariate Mixture Models. Why is taking so long?

Neither of those code snippets run, so I canâ€™t give you a reference for performance. Do you have a reproducible example?

Thank you for your time. You are right, I have one typo in the first snippet (`y` vs `data` in the likelihood) and one PyMC version definition problem in the second (`pm.distributions.transforms.ordered` vs `pm.distributions.transforms.univariate_ordered`).

I already edited the original post. Now both snippets should run, although rather slowly. Any feedback is welcomed.

So that first example takes 2 minutes to sample on my machine and it doesnâ€™t sample particularly well given how simple the model is. Not sure thatâ€™s useful, but maybe it provides some reference.

One thing that is going to slow sampling quite a bit (and hurt sampling over all) is the use of the categorical parameters `z`. It is strongly recommended to marginalize these parameters out. You can see an example of that here.

1 Like

Iâ€™d also make sure you followed the official PyMC installation guide and that youâ€™re not using the (default and very slow) numpy BLAS. Youâ€™ll be getting a warning when you import PyMC if this is the case.

1 Like

Thank you for the feedback. I checked and it is using NUTS

@jessegrabowski was asking about packages (BLAS) that live deep in the bowels of PyMC/PyTensor. The easiest way to tell is to check whether you get any warnings when you first `import pymc`.

1 Like

You were rigth, when PyMC is imported there is this warning,

``````WARNING (pytensor.configdefaults): g++ not detected!  PyTensor will be unable to compile C-implementations and will default to Python. Performance may be severely degraded. To remove this warning, set PyTensor flags cxx to an empty string.
WARNING (pytensor.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
``````

But I installed it using conda forge as described in the link you provided. I didnâ€™t install JAX nor Nutpie support. What could be the issue?

Do you have an M1/M2 mac?

No, Ubuntu 22.04.3 LTS

Are you positive you have the correct environment activated when you import pymc? Especially if youâ€™re in an IDE like spyder.

Iâ€™m asking because it shouldnâ€™t be possible to get these errors if you install via conda-forge. If youâ€™re sure everything is right Iâ€™d nuke the env and start over

I just reinstalled PyMC5 using the link you provided and I obtained the same results (about BLAS). The other additional packages I install in the same environment is jupyterlab and matplotlib. I copy the entire installation procedure and the outputs,

``````conda create -c conda-forge -n pymc5_v2 "pymc>=5"
Retrieving notices: ...working... done
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

environment location: /home/fran/miniconda3/envs/pymc5_v2

added / updated specs:
- pymc[version='>=5']

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
filelock-3.13.1            |     pyhd8ed1ab_0          15 KB  conda-forge
libnghttp2-1.55.1          |       h47da74e_0         613 KB  conda-forge
libsqlite-3.44.0           |       h2797004_0         826 KB  conda-forge
ncurses-6.4                |       h59595ed_2         864 KB  conda-forge
pandas-2.1.2               |  py311h320fe9a_0        14.3 MB  conda-forge
pymc-5.9.1                 |       hd8ed1ab_0          11 KB  conda-forge
pymc-base-5.9.1            |     pyhd8ed1ab_0         310 KB  conda-forge
wheel-0.41.3               |     pyhd8ed1ab_0          57 KB  conda-forge
------------------------------------------------------------
Total:        17.0 MB

The following NEW packages will be INSTALLED:

_libgcc_mutex      conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
_openmp_mutex      conda-forge/linux-64::_openmp_mutex-4.5-2_gnu
arviz              conda-forge/noarch::arviz-0.16.1-pyhd8ed1ab_1
atk-1.0            conda-forge/linux-64::atk-1.0-2.38.0-hd4edc92_1
brotli             conda-forge/linux-64::brotli-1.1.0-hd590300_1
brotli-bin         conda-forge/linux-64::brotli-bin-1.1.0-hd590300_1
bzip2              conda-forge/linux-64::bzip2-1.0.8-h7f98852_4
c-ares             conda-forge/linux-64::c-ares-1.20.1-hd590300_1
ca-certificates    conda-forge/linux-64::ca-certificates-2023.7.22-hbcca054_0
cached-property    conda-forge/noarch::cached-property-1.5.2-hd8ed1ab_1
cached_property    conda-forge/noarch::cached_property-1.5.2-pyha770c72_1
cachetools         conda-forge/noarch::cachetools-5.3.2-pyhd8ed1ab_0
cairo              conda-forge/linux-64::cairo-1.18.0-h3faef2a_0
certifi            conda-forge/noarch::certifi-2023.7.22-pyhd8ed1ab_0
cloudpickle        conda-forge/noarch::cloudpickle-3.0.0-pyhd8ed1ab_0
cons               conda-forge/noarch::cons-0.4.6-pyhd8ed1ab_0
contourpy          conda-forge/linux-64::contourpy-1.1.1-py311h9547e67_1
cycler             conda-forge/noarch::cycler-0.12.1-pyhd8ed1ab_0
etuples            conda-forge/noarch::etuples-0.3.9-pyhd8ed1ab_0
expat              conda-forge/linux-64::expat-2.5.0-hcb278e6_1
fastprogress       conda-forge/noarch::fastprogress-1.0.3-pyhd8ed1ab_0
filelock           conda-forge/noarch::filelock-3.13.1-pyhd8ed1ab_0
font-ttf-dejavu-s~ conda-forge/noarch::font-ttf-dejavu-sans-mono-2.37-hab24e00_0
font-ttf-inconsol~ conda-forge/noarch::font-ttf-inconsolata-3.000-h77eed37_0
font-ttf-source-c~ conda-forge/noarch::font-ttf-source-code-pro-2.038-h77eed37_0
font-ttf-ubuntu    conda-forge/noarch::font-ttf-ubuntu-0.83-hab24e00_0
fontconfig         conda-forge/linux-64::fontconfig-2.14.2-h14ed4e7_0
fonts-conda-ecosy~ conda-forge/noarch::fonts-conda-ecosystem-1-0
fonts-conda-forge  conda-forge/noarch::fonts-conda-forge-1-0
fonttools          conda-forge/linux-64::fonttools-4.43.1-py311h459d7ec_0
freetype           conda-forge/linux-64::freetype-2.12.1-h267a509_2
fribidi            conda-forge/linux-64::fribidi-1.0.10-h36c2ea0_0
gdk-pixbuf         conda-forge/linux-64::gdk-pixbuf-2.42.10-h829c605_4
gettext            conda-forge/linux-64::gettext-0.21.1-h27087fc_0
giflib             conda-forge/linux-64::giflib-5.2.1-h0b41bf4_3
graphite2          conda-forge/linux-64::graphite2-1.3.13-h58526e2_1001
graphviz           conda-forge/linux-64::graphviz-8.1.0-h28d9a01_0
gtk2               conda-forge/linux-64::gtk2-2.24.33-h90689f9_2
gts                conda-forge/linux-64::gts-0.7.6-h977cf35_4
h5netcdf           conda-forge/noarch::h5netcdf-1.2.0-pyhd8ed1ab_0
h5py               conda-forge/linux-64::h5py-3.10.0-nompi_py311h3839ddf_100
harfbuzz           conda-forge/linux-64::harfbuzz-8.2.1-h3d44ed6_0
hdf5               conda-forge/linux-64::hdf5-1.14.2-nompi_h4f84152_100
icu                conda-forge/linux-64::icu-73.2-h59595ed_0
keyutils           conda-forge/linux-64::keyutils-1.6.1-h166bdaf_0
kiwisolver         conda-forge/linux-64::kiwisolver-1.4.5-py311h9547e67_1
krb5               conda-forge/linux-64::krb5-1.21.2-h659d440_0
lcms2              conda-forge/linux-64::lcms2-2.15-hb7c19ff_3
ld_impl_linux-64   conda-forge/linux-64::ld_impl_linux-64-2.40-h41732ed_0
lerc               conda-forge/linux-64::lerc-4.0.0-h27087fc_0
libaec             conda-forge/linux-64::libaec-1.1.2-h59595ed_1
libblas            conda-forge/linux-64::libblas-3.9.0-19_linux64_openblas
libbrotlicommon    conda-forge/linux-64::libbrotlicommon-1.1.0-hd590300_1
libbrotlidec       conda-forge/linux-64::libbrotlidec-1.1.0-hd590300_1
libbrotlienc       conda-forge/linux-64::libbrotlienc-1.1.0-hd590300_1
libcblas           conda-forge/linux-64::libcblas-3.9.0-19_linux64_openblas
libcurl            conda-forge/linux-64::libcurl-8.4.0-hca28451_0
libdeflate         conda-forge/linux-64::libdeflate-1.19-hd590300_0
libedit            conda-forge/linux-64::libedit-3.1.20191231-he28a2e2_2
libev              conda-forge/linux-64::libev-4.33-h516909a_1
libexpat           conda-forge/linux-64::libexpat-2.5.0-hcb278e6_1
libffi             conda-forge/linux-64::libffi-3.4.2-h7f98852_5
libgcc-ng          conda-forge/linux-64::libgcc-ng-13.2.0-h807b86a_2
libgd              conda-forge/linux-64::libgd-2.3.3-h119a65a_9
libgfortran-ng     conda-forge/linux-64::libgfortran-ng-13.2.0-h69a702a_2
libgfortran5       conda-forge/linux-64::libgfortran5-13.2.0-ha4646dd_2
libglib            conda-forge/linux-64::libglib-2.78.0-hebfc3b9_0
libgomp            conda-forge/linux-64::libgomp-13.2.0-h807b86a_2
libiconv           conda-forge/linux-64::libiconv-1.17-h166bdaf_0
libjpeg-turbo      conda-forge/linux-64::libjpeg-turbo-3.0.0-hd590300_1
liblapack          conda-forge/linux-64::liblapack-3.9.0-19_linux64_openblas
libnghttp2         conda-forge/linux-64::libnghttp2-1.55.1-h47da74e_0
libnsl             conda-forge/linux-64::libnsl-2.0.1-hd590300_0
libopenblas        conda-forge/linux-64::libopenblas-0.3.24-pthreads_h413a1c8_0
libpng             conda-forge/linux-64::libpng-1.6.39-h753d276_0
librsvg            conda-forge/linux-64::librsvg-2.56.3-h98fae49_0
libsqlite          conda-forge/linux-64::libsqlite-3.44.0-h2797004_0
libssh2            conda-forge/linux-64::libssh2-1.11.0-h0841786_0
libstdcxx-ng       conda-forge/linux-64::libstdcxx-ng-13.2.0-h7e041cc_2
libtiff            conda-forge/linux-64::libtiff-4.6.0-ha9c0a0a_2
libtool            conda-forge/linux-64::libtool-2.4.7-h27087fc_0
libuuid            conda-forge/linux-64::libuuid-2.38.1-h0b41bf4_0
libwebp            conda-forge/linux-64::libwebp-1.3.2-h658648e_1
libwebp-base       conda-forge/linux-64::libwebp-base-1.3.2-hd590300_0
libxcb             conda-forge/linux-64::libxcb-1.15-h0b41bf4_0
libxml2            conda-forge/linux-64::libxml2-2.11.5-h232c23b_1
libzlib            conda-forge/linux-64::libzlib-1.2.13-hd590300_5
logical-unificati~ conda-forge/noarch::logical-unification-0.4.6-pyhd8ed1ab_0
matplotlib-base    conda-forge/linux-64::matplotlib-base-3.8.0-py311h54ef318_2
minikanren         conda-forge/noarch::minikanren-1.0.3-pyhd8ed1ab_0
multipledispatch   conda-forge/noarch::multipledispatch-0.6.0-py_0
munkres            conda-forge/noarch::munkres-1.1.4-pyh9f0ad1d_0
ncurses            conda-forge/linux-64::ncurses-6.4-h59595ed_2
numpy              conda-forge/linux-64::numpy-1.25.2-py311h64a7726_0
openjpeg           conda-forge/linux-64::openjpeg-2.5.0-h488ebb8_3
openssl            conda-forge/linux-64::openssl-3.1.4-hd590300_0
packaging          conda-forge/noarch::packaging-23.2-pyhd8ed1ab_0
pandas             conda-forge/linux-64::pandas-2.1.2-py311h320fe9a_0
pango              conda-forge/linux-64::pango-1.50.14-ha41ecd1_2
pcre2              conda-forge/linux-64::pcre2-10.40-hc3806b6_0
pillow             conda-forge/linux-64::pillow-10.1.0-py311ha6c5da5_0
pip                conda-forge/noarch::pip-23.3.1-pyhd8ed1ab_0
pixman             conda-forge/linux-64::pixman-0.42.2-h59595ed_0
pthread-stubs      conda-forge/linux-64::pthread-stubs-0.4-h36c2ea0_1001
pymc               conda-forge/noarch::pymc-5.9.1-hd8ed1ab_0
pymc-base          conda-forge/noarch::pymc-base-5.9.1-pyhd8ed1ab_0
pyparsing          conda-forge/noarch::pyparsing-3.1.1-pyhd8ed1ab_0
pytensor           pkgs/main/linux-64::pytensor-2.13.1-py311ha02d727_0
pytensor-base      conda-forge/linux-64::pytensor-base-2.17.3-py311h320fe9a_0
python             conda-forge/linux-64::python-3.11.6-hab00c5b_0_cpython
python-dateutil    conda-forge/noarch::python-dateutil-2.8.2-pyhd8ed1ab_0
python-graphviz    conda-forge/noarch::python-graphviz-0.20.1-pyh22cad53_0
python-tzdata      conda-forge/noarch::python-tzdata-2023.3-pyhd8ed1ab_0
python_abi         conda-forge/linux-64::python_abi-3.11-4_cp311
pytz               conda-forge/noarch::pytz-2023.3.post1-pyhd8ed1ab_0
readline           conda-forge/linux-64::readline-8.2-h8228510_1
scipy              conda-forge/linux-64::scipy-1.11.3-py311h64a7726_1
setuptools         conda-forge/noarch::setuptools-68.2.2-pyhd8ed1ab_0
six                conda-forge/noarch::six-1.16.0-pyh6c4a22f_0
tk                 conda-forge/linux-64::tk-8.6.13-h2797004_0
toolz              conda-forge/noarch::toolz-0.12.0-pyhd8ed1ab_0
typing-extensions  conda-forge/noarch::typing-extensions-4.8.0-hd8ed1ab_0
typing_extensions  conda-forge/noarch::typing_extensions-4.8.0-pyha770c72_0
tzdata             conda-forge/noarch::tzdata-2023c-h71feb2d_0
wheel              conda-forge/noarch::wheel-0.41.3-pyhd8ed1ab_0
xarray             conda-forge/noarch::xarray-2023.10.1-pyhd8ed1ab_0
xarray-einstats    conda-forge/noarch::xarray-einstats-0.6.0-pyhd8ed1ab_0
xorg-kbproto       conda-forge/linux-64::xorg-kbproto-1.0.7-h7f98852_1002
xorg-libice        conda-forge/linux-64::xorg-libice-1.1.1-hd590300_0
xorg-libsm         conda-forge/linux-64::xorg-libsm-1.2.4-h7391055_0
xorg-libx11        conda-forge/linux-64::xorg-libx11-1.8.7-h8ee46fc_0
xorg-libxau        conda-forge/linux-64::xorg-libxau-1.0.11-hd590300_0
xorg-libxdmcp      conda-forge/linux-64::xorg-libxdmcp-1.1.3-h7f98852_0
xorg-libxext       conda-forge/linux-64::xorg-libxext-1.3.4-h0b41bf4_2
xorg-libxrender    conda-forge/linux-64::xorg-libxrender-0.9.11-hd590300_0
xorg-renderproto   conda-forge/linux-64::xorg-renderproto-0.11.1-h7f98852_1002
xorg-xextproto     conda-forge/linux-64::xorg-xextproto-7.3.0-h0b41bf4_1003
xorg-xproto        conda-forge/linux-64::xorg-xproto-7.0.31-h7f98852_1007
xz                 conda-forge/linux-64::xz-5.2.6-h166bdaf_0
zlib               conda-forge/linux-64::zlib-1.2.13-hd590300_5
zstd               conda-forge/linux-64::zstd-1.5.5-hfc55251_0

Proceed ([y]/n)?

Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: |
-
done
#
# To activate this environment, use
#
#     \$ conda activate pymc5_v2
#
# To deactivate an active environment, use
#
#     \$ conda deactivate

(base) fran@burns:~\$ conda activate pymc5_v2
(pymc5_v2) fran@burns:~\$ conda install jupyterlab matplotlib
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

environment location: /home/fran/miniconda3/envs/pymc5_v2

added / updated specs:
- jupyterlab
- matplotlib

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
brotli-python-1.0.9        |  py311h6a678d5_7         318 KB
harfbuzz-4.3.0             |       hf52aaf7_2         1.3 MB
libxslt-1.1.37             |       h5eee18b_1         266 KB
matplotlib-3.8.0           |  py311h06a4308_0           8 KB
pyqt-5.15.10               |  py311h6a678d5_0         5.7 MB
pyqt5-sip-12.13.0          |  py311h5eee18b_0          95 KB
qt-main-5.15.2             |      h53bd1ea_10        53.7 MB
sip-6.7.12                 |  py311h6a678d5_0         603 KB
urllib3-1.26.18            |  py311h06a4308_0         251 KB
------------------------------------------------------------
Total:        62.1 MB

The following NEW packages will be INSTALLED:

aiofiles           pkgs/main/linux-64::aiofiles-22.1.0-py311h06a4308_0
aiosqlite          pkgs/main/linux-64::aiosqlite-0.18.0-py311h06a4308_0
anyio              pkgs/main/linux-64::anyio-3.5.0-py311h06a4308_0
argon2-cffi        pkgs/main/noarch::argon2-cffi-21.3.0-pyhd3eb1b0_0
argon2-cffi-bindi~ pkgs/main/linux-64::argon2-cffi-bindings-21.2.0-py311h5eee18b_0
asttokens          pkgs/main/noarch::asttokens-2.0.5-pyhd3eb1b0_0
attrs              pkgs/main/linux-64::attrs-23.1.0-py311h06a4308_0
babel              pkgs/main/linux-64::babel-2.11.0-py311h06a4308_0
backcall           pkgs/main/noarch::backcall-0.2.0-pyhd3eb1b0_0
beautifulsoup4     pkgs/main/linux-64::beautifulsoup4-4.12.2-py311h06a4308_0
bleach             pkgs/main/noarch::bleach-4.1.0-pyhd3eb1b0_0
brotli-python      pkgs/main/linux-64::brotli-python-1.0.9-py311h6a678d5_7
cffi               pkgs/main/linux-64::cffi-1.15.1-py311h5eee18b_3
charset-normalizer pkgs/main/noarch::charset-normalizer-2.0.4-pyhd3eb1b0_0
comm               pkgs/main/linux-64::comm-0.1.2-py311h06a4308_0
cryptography       pkgs/main/linux-64::cryptography-41.0.3-py311hdda0065_0
cyrus-sasl         pkgs/main/linux-64::cyrus-sasl-2.1.28-h52b45da_1
dbus               pkgs/main/linux-64::dbus-1.13.18-hb2f20db_0
debugpy            pkgs/main/linux-64::debugpy-1.6.7-py311h6a678d5_0
decorator          pkgs/main/noarch::decorator-5.1.1-pyhd3eb1b0_0
defusedxml         pkgs/main/noarch::defusedxml-0.7.1-pyhd3eb1b0_0
entrypoints        pkgs/main/linux-64::entrypoints-0.4-py311h06a4308_0
executing          pkgs/main/noarch::executing-0.8.3-pyhd3eb1b0_0
glib               pkgs/main/linux-64::glib-2.69.1-he621ea3_2
gobject-introspec~ pkgs/main/linux-64::gobject-introspection-1.72.0-py311hbb6d50b_2
gst-plugins-base   pkgs/main/linux-64::gst-plugins-base-1.14.1-h6a678d5_1
gstreamer          pkgs/main/linux-64::gstreamer-1.14.1-h5eee18b_1
idna               pkgs/main/linux-64::idna-3.4-py311h06a4308_0
ipykernel          pkgs/main/linux-64::ipykernel-6.25.0-py311h92b7b1e_0
ipython            pkgs/main/linux-64::ipython-8.15.0-py311h06a4308_0
ipython_genutils   pkgs/main/noarch::ipython_genutils-0.2.0-pyhd3eb1b0_1
jedi               pkgs/main/linux-64::jedi-0.18.1-py311h06a4308_1
jinja2             pkgs/main/linux-64::jinja2-3.1.2-py311h06a4308_0
jpeg               pkgs/main/linux-64::jpeg-9e-h5eee18b_1
json5              pkgs/main/noarch::json5-0.9.6-pyhd3eb1b0_0
jsonschema         pkgs/main/linux-64::jsonschema-4.17.3-py311h06a4308_0
jupyter_client     pkgs/main/linux-64::jupyter_client-7.4.9-py311h06a4308_0
jupyter_core       pkgs/main/linux-64::jupyter_core-5.3.0-py311h06a4308_0
jupyter_events     pkgs/main/linux-64::jupyter_events-0.6.3-py311h06a4308_0
jupyter_server     pkgs/main/linux-64::jupyter_server-1.23.4-py311h06a4308_0
jupyter_server_fi~ pkgs/main/linux-64::jupyter_server_fileid-0.9.0-py311h06a4308_0
jupyter_server_yd~ pkgs/main/linux-64::jupyter_server_ydoc-0.8.0-py311h06a4308_1
jupyter_ydoc       pkgs/main/linux-64::jupyter_ydoc-0.2.4-py311h06a4308_0
jupyterlab         pkgs/main/linux-64::jupyterlab-3.6.3-py311h06a4308_0
jupyterlab_pygmen~ pkgs/main/noarch::jupyterlab_pygments-0.1.2-py_0
jupyterlab_server  pkgs/main/linux-64::jupyterlab_server-2.22.0-py311h06a4308_0
libclang           pkgs/main/linux-64::libclang-14.0.6-default_hc6dbbc7_1
libclang13         pkgs/main/linux-64::libclang13-14.0.6-default_he11475f_1
libcups            pkgs/main/linux-64::libcups-2.4.2-h2d74bed_1
libllvm14          pkgs/main/linux-64::libllvm14-14.0.6-hdb19cb5_3
libpq              pkgs/main/linux-64::libpq-12.15-hdbd6064_1
libsodium          pkgs/main/linux-64::libsodium-1.0.18-h7b6447c_0
libxkbcommon       pkgs/main/linux-64::libxkbcommon-1.0.1-h5eee18b_1
libxslt            pkgs/main/linux-64::libxslt-1.1.37-h5eee18b_1
lxml               pkgs/main/linux-64::lxml-4.9.3-py311hdbbb534_0
markupsafe         pkgs/main/linux-64::markupsafe-2.1.1-py311h5eee18b_0
matplotlib         pkgs/main/linux-64::matplotlib-3.8.0-py311h06a4308_0
matplotlib-inline  pkgs/main/linux-64::matplotlib-inline-0.1.6-py311h06a4308_0
mistune            pkgs/main/linux-64::mistune-0.8.4-py311h5eee18b_1000
mysql              pkgs/main/linux-64::mysql-5.7.24-h721c034_2
nbclassic          pkgs/main/linux-64::nbclassic-0.5.5-py311h06a4308_0
nbclient           pkgs/main/linux-64::nbclient-0.5.13-py311h06a4308_0
nbconvert          pkgs/main/linux-64::nbconvert-6.5.4-py311h06a4308_0
nbformat           pkgs/main/linux-64::nbformat-5.9.2-py311h06a4308_0
nest-asyncio       pkgs/main/linux-64::nest-asyncio-1.5.6-py311h06a4308_0
ninja              pkgs/main/linux-64::ninja-1.10.2-h06a4308_5
ninja-base         pkgs/main/linux-64::ninja-base-1.10.2-hd09550d_5
notebook           pkgs/main/linux-64::notebook-6.5.4-py311h06a4308_1
notebook-shim      pkgs/main/linux-64::notebook-shim-0.2.2-py311h06a4308_0
pandocfilters      pkgs/main/noarch::pandocfilters-1.5.0-pyhd3eb1b0_0
parso              pkgs/main/noarch::parso-0.8.3-pyhd3eb1b0_0
pcre               pkgs/main/linux-64::pcre-8.45-h295c915_0
pexpect            pkgs/main/noarch::pexpect-4.8.0-pyhd3eb1b0_3
pickleshare        pkgs/main/noarch::pickleshare-0.7.5-pyhd3eb1b0_1003
platformdirs       pkgs/main/linux-64::platformdirs-3.10.0-py311h06a4308_0
ply                pkgs/main/linux-64::ply-3.11-py311h06a4308_0
prometheus_client  pkgs/main/linux-64::prometheus_client-0.14.1-py311h06a4308_0
prompt-toolkit     pkgs/main/linux-64::prompt-toolkit-3.0.36-py311h06a4308_0
psutil             pkgs/main/linux-64::psutil-5.9.0-py311h5eee18b_0
ptyprocess         pkgs/main/noarch::ptyprocess-0.7.0-pyhd3eb1b0_2
pure_eval          pkgs/main/noarch::pure_eval-0.2.2-pyhd3eb1b0_0
pycparser          pkgs/main/noarch::pycparser-2.21-pyhd3eb1b0_0
pygments           pkgs/main/linux-64::pygments-2.15.1-py311h06a4308_1
pyopenssl          pkgs/main/linux-64::pyopenssl-23.2.0-py311h06a4308_0
pyqt               pkgs/main/linux-64::pyqt-5.15.10-py311h6a678d5_0
pyqt5-sip          pkgs/main/linux-64::pyqt5-sip-12.13.0-py311h5eee18b_0
pyrsistent         pkgs/main/linux-64::pyrsistent-0.18.0-py311h5eee18b_0
pysocks            pkgs/main/linux-64::pysocks-1.7.1-py311h06a4308_0
python-fastjsonsc~ pkgs/main/linux-64::python-fastjsonschema-2.16.2-py311h06a4308_0
python-json-logger pkgs/main/linux-64::python-json-logger-2.0.7-py311h06a4308_0
pyyaml             pkgs/main/linux-64::pyyaml-6.0.1-py311h5eee18b_0
pyzmq              pkgs/main/linux-64::pyzmq-23.2.0-py311h6a678d5_0
qt-main            pkgs/main/linux-64::qt-main-5.15.2-h53bd1ea_10
requests           pkgs/main/linux-64::requests-2.31.0-py311h06a4308_0
rfc3339-validator  pkgs/main/linux-64::rfc3339-validator-0.1.4-py311h06a4308_0
rfc3986-validator  pkgs/main/linux-64::rfc3986-validator-0.1.1-py311h06a4308_0
send2trash         pkgs/main/noarch::send2trash-1.8.0-pyhd3eb1b0_1
sip                pkgs/main/linux-64::sip-6.7.12-py311h6a678d5_0
sniffio            pkgs/main/linux-64::sniffio-1.2.0-py311h06a4308_1
soupsieve          pkgs/main/linux-64::soupsieve-2.5-py311h06a4308_0
sqlite             pkgs/main/linux-64::sqlite-3.41.2-h5eee18b_0
stack_data         pkgs/main/noarch::stack_data-0.2.0-pyhd3eb1b0_0
terminado          pkgs/main/linux-64::terminado-0.17.1-py311h06a4308_0
tinycss2           pkgs/main/linux-64::tinycss2-1.2.1-py311h06a4308_0
tornado            pkgs/main/linux-64::tornado-6.3.3-py311h5eee18b_0
traitlets          pkgs/main/linux-64::traitlets-5.7.1-py311h06a4308_0
urllib3            pkgs/main/linux-64::urllib3-1.26.18-py311h06a4308_0
wcwidth            pkgs/main/noarch::wcwidth-0.2.5-pyhd3eb1b0_0
webencodings       pkgs/main/linux-64::webencodings-0.5.1-py311h06a4308_1
websocket-client   pkgs/main/linux-64::websocket-client-0.58.0-py311h06a4308_4
y-py               pkgs/main/linux-64::y-py-0.5.9-py311h52d8a92_0
yaml               pkgs/main/linux-64::yaml-0.2.5-h7b6447c_0
ypy-websocket      pkgs/main/linux-64::ypy-websocket-0.8.2-py311h06a4308_0
zeromq             pkgs/main/linux-64::zeromq-4.3.4-h2531618_0

The following packages will be REMOVED:

libglib-2.78.0-hebfc3b9_0
libjpeg-turbo-3.0.0-hd590300_1
openjpeg-2.5.0-h488ebb8_3

The following packages will be UPDATED:

ca-certificates    conda-forge::ca-certificates-2023.7.2~ --> pkgs/main::ca-certificates-2023.08.22-h06a4308_0
graphite2          conda-forge::graphite2-1.3.13-h58526e~ --> pkgs/main::graphite2-1.3.14-h295c915_1
libedit            conda-forge::libedit-3.1.20191231-he2~ --> pkgs/main::libedit-3.1.20221030-h5eee18b_0
xz                       conda-forge::xz-5.2.6-h166bdaf_0 --> pkgs/main::xz-5.4.2-h5eee18b_0

The following packages will be SUPERSEDED by a higher-priority channel:

atk-1.0            conda-forge::atk-1.0-2.38.0-hd4edc92_1 --> pkgs/main::atk-1.0-2.36.0-ha1a6a79_0
cairo                conda-forge::cairo-1.18.0-h3faef2a_0 --> pkgs/main::cairo-1.16.0-hb05425b_5
certifi            conda-forge/noarch::certifi-2023.7.22~ --> pkgs/main/linux-64::certifi-2023.7.22-py311h06a4308_0
gdk-pixbuf         conda-forge::gdk-pixbuf-2.42.10-h829c~ --> pkgs/main::gdk-pixbuf-2.42.10-h5eee18b_0
graphviz           conda-forge::graphviz-8.1.0-h28d9a01_0 --> pkgs/main::graphviz-2.50.0-h3cd0ef9_0
gtk2                 conda-forge::gtk2-2.24.33-h90689f9_2 --> pkgs/main::gtk2-2.24.33-h73c1081_2
gts                     conda-forge::gts-0.7.6-h977cf35_4 --> pkgs/main::gts-0.7.6-hb67d8dd_3
harfbuzz           conda-forge::harfbuzz-8.2.1-h3d44ed6_0 --> pkgs/main::harfbuzz-4.3.0-hf52aaf7_2
krb5                  conda-forge::krb5-1.21.2-h659d440_0 --> pkgs/main::krb5-1.20.1-h143b758_1
lcms2                  conda-forge::lcms2-2.15-hb7c19ff_3 --> pkgs/main::lcms2-2.12-h3be6417_0
lerc                   conda-forge::lerc-4.0.0-h27087fc_0 --> pkgs/main::lerc-3.0-h295c915_0
libcurl             conda-forge::libcurl-8.4.0-hca28451_0 --> pkgs/main::libcurl-8.2.1-h251f7ec_0
libdeflate         conda-forge::libdeflate-1.19-hd590300~ --> pkgs/main::libdeflate-1.17-h5eee18b_1
libgd                 conda-forge::libgd-2.3.3-h119a65a_9 --> pkgs/main::libgd-2.3.3-h695aa2c_1
librsvg            conda-forge::librsvg-2.56.3-h98fae49_0 --> pkgs/main::librsvg-2.54.4-h36cc946_3
libtiff             conda-forge::libtiff-4.6.0-ha9c0a0a_2 --> pkgs/main::libtiff-4.5.1-h6a678d5_0
libwebp             conda-forge::libwebp-1.3.2-h658648e_1 --> pkgs/main::libwebp-1.3.2-h11a3e52_0
libxml2            conda-forge::libxml2-2.11.5-h232c23b_1 --> pkgs/main::libxml2-2.10.4-hf1b16e4_1
pango               conda-forge::pango-1.50.14-ha41ecd1_2 --> pkgs/main::pango-1.50.7-h05da053_0
pillow             conda-forge::pillow-10.1.0-py311ha6c5~ --> pkgs/main::pillow-9.4.0-py311h6a678d5_1

Proceed ([y]/n)?
``````

Thank you for the feedback. I was aware of the existence of the marginalized version of a GMM, but I had the idea that in that scheme, you loose information about the categorical variable z and you cannot do inference about the probability of a given point to be in a specific cluster. Is this idea correct?

You can recover the probability afterwards. We show an example at the end of this blog: Out of model predictions with PyMC - PyMC Labs

Fantastic! I wasnâ€™t aware of that tutorial. Thank you again!

I repeated the procedure to install `PyMC5` with `conda-forge` and had the same errors. However, I found this very old thread about a similar problem with `Theano`. With this in mind, I installed `PyMC` with `conda-forge` in the base environment. In this case, it complained about g++ (which I then installed with `build-essentials`) and then inform these errors:

``````configparser.NoSectionError: No section: 'blas'
KeyError: 'blas__ldflags'
``````

But surprisingly, inside the virtual environment now I have no further warnings. In any case, the sample is still slow so I will try the marginalized version