2

How do I make sympy’s lambdify accept more function names, like a Normal function, for example? To make something like this work:

lambdify(('x',), 'NPDF(x, 0, 1)')

I don’t mind using the Normal function from the sympy statistics module, as long as it doesn’t create a new Normal() distribution object every time the lambda gets called.

taylor swift
  • 2,039
  • 1
  • 15
  • 29

1 Answers1

1

If you have a numerical implementation of the function you want to use, pass it in the second argument, like

lambdify(x, NPDF(x, 0, 1), modules=['numpy', {'NPDF': NPDF_implementation}])
asmeurer
  • 86,894
  • 26
  • 169
  • 240
  • Do I need the `'numpy'` in front? And is there any way to use the built in normal distribution from sympy? – taylor swift Jul 11 '16 at 19:38
  • 1
    The 'numpy' in front is if you also want to use numpy (otherwise, only that one function will be defined for the lambdified function). – asmeurer Jul 11 '16 at 19:52