Hi, this might be easiest to achive with boost and compiled expression machinery. Consider
from dolfin import *
code = '''
#include <boost/math/distributions/inverse_gaussian.hpp>
using boost::math::inverse_gaussian;
namespace dolfin {
class IG : public Expression
{
public:
IG() : Expression()
{
_a = 1;
_b = 1;
ig = inverse_gaussian(_a, _b);
}
// Probability density function
void eval(Array<double>& values, const Array<double>& x) const
{
values[0] = pdf(ig, x[0]);
}
// Change alpha, beta;
void set(double alpha, double beta)
{
_a = alpha;
_b = beta;
ig = inverse_gaussian(_a, _b);
}
private:
inverse_gaussian ig;
double _a, _b;
};
}'''
ig = Expression(code)
mesh = IntervalMesh(100, 0, 3)
plot(ig, mesh=mesh, interactive=True)
ig.set(1, 5)
plot(ig, mesh=mesh, interactive=True)