# Feasability of pm.Potential usage

**URL:** <https://discourse.pymc.io/t/feasability-of-pm-potential-usage/14749>\
**Category:** v5\
**Created:** [July 9, 2024, 9:17am UTC](https://discourse.pymc.io/t/feasability-of-pm-potential-usage/14749 "2024-07-09T09:17:07Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [July 9, 2024, 3:27pm UTC](https://discourse.pymc.io/t/feasability-of-pm-potential-usage/14749/2 "2024-07-09T15:27:00Z")

</div>

Arbitrarily complex python code can be wrapped into pytensor `Ops` for inclusion in PyMC models, see [here](https://www.pymc.io/projects/examples/en/latest/howto/blackbox_external_likelihood_numpy.html) for an example focusing on likelihoods, or perhaps [here](https://discourse.pymc.io/t/pytensor-scan-of-an-array-with-pymc-sampling/14108/8) for an example that wraps a scipy optimization routine.

Depending on the nature of the simulator, you might even be able to express it in pure pytensor, which would allow you to differentiate through the simulations (and compile it to numba/JAX for accelerated sampling). Some comments (and maybe a similar problem?) [here](https://discourse.pymc.io/t/casting-matrix-inversion-error/14273/4).

---

_[View the full topic](https://discourse.pymc.io/t/feasability-of-pm-potential-usage/14749)._
