Search code examples
juliadifferentialequations.jl

Does the command "expectation" in Distributions.jl not work recently?


I tried the following commands

using DiffEqUncertainty, Distributions
expectation(g, prob, u0_dist, p)

Of course, the second command is not correct and many arguments are still missing, but it still serves for the purpose of nWME (not Working Minimal Example).

The error message I received is "ERROR: UndefVarError: expectation not defined". Am I missing some other packages to run "expectation" command?

Please help. Thank you.


Solution

  • DiffEqUncertainty exports expectation, so it should be defined:

    https://github.com/SciML/DiffEqUncertainty.jl/blob/master/src/DiffEqUncertainty.jl

    In general when this error occurs despite things being exported by a package it is down to one of two issues:

    1. An outdated package version, which does not export the same functions; or
    2. A name clash, i.e. another package exporting a function with the same name - in this case you should get a warning, and qualifying the function (i.e. DiffEqUncertainty.expectation) should get around the issue.