# Bug in Expectations.jl?

**URL:** <https://discourse.julialang.org/t/bug-in-expectations-jl/15524>\
**Category:** General Usage\
**Created:** [September 26, 2018, 5:22pm UTC](https://discourse.julialang.org/t/bug-in-expectations-jl/15524 "2018-09-26T17:22:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Post date:** [September 26, 2018, 5:22pm UTC](https://discourse.julialang.org/t/bug-in-expectations-jl/15524/1 "2018-09-26T17:22:33Z")

</div>

Hey everyone,

I wanted to use `Expectations.jl` and I think this constitutes an error?

```julia
using Distributions, Expectations
E = expectation(Normal(1, 1))
E(x -> x)

```

with the result being

```julia
julia> E(x -> x)
5.778544334733716e-17

```

where it clearly should be 1. Am I missing something obvious or should I file an issue?

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [September 26, 2018, 6:01pm UTC](https://discourse.julialang.org/t/bug-in-expectations-jl/15524/2 "2018-09-26T18:01:47Z")

</div>

Hmm… Try it again? I didn’t just try it right now but I did something similar a few days ago and did not have this problem.

If you still get the problem then I’d suggest filing an issue.

---

<div class="post-metadata">

**Author:** ![ianfiske](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@ianfiske](https://discourse.julialang.org/u/ianfiske)\
**Post date:** [September 26, 2018, 6:28pm UTC](https://discourse.julialang.org/t/bug-in-expectations-jl/15524/3 "2018-09-26T18:28:45Z")

</div>

I get the same thing. Please file an issue with the package author in github. Or dig in and make a PR 😉

---

<div class="post-metadata">

**Author:** ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Post date:** [September 26, 2018, 6:39pm UTC](https://discourse.julialang.org/t/bug-in-expectations-jl/15524/4 "2018-09-26T18:39:44Z")

</div>

[https://github.com/econtoolkit/Expectations.jl/issues/23](https://github.com/econtoolkit/Expectations.jl/issues/23)

Filed an issue 🙂

---

<div class="post-metadata">

**Author:** ![arnavsood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/arnavsood/32/4675_2.png) [@arnavsood](https://discourse.julialang.org/u/arnavsood)\
**Post date:** [September 27, 2018, 6:00am UTC](https://discourse.julialang.org/t/bug-in-expectations-jl/15524/5 "2018-09-27T06:00:00Z")

</div>

One of the package maintainers here. Just an update that after the issue was filed, I caught the bug (broadcasting error in the normal quadrature routine, which also impacted `LogNormal`) and added some tests with different parameters. The current `master` should be kosher, and we also tagged a new release 1.0.2.

Thanks for catching this and reporting. I’ll try to stay on top of the Discourse, but I’m more plugged into issues on the repo or emails (`arnav.sood@ubc.ca`).
