Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11816 > unrolled thread

Re: Linear combinations of Expectation of EmpiricalDistribution

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-09-19 08:58 +0000
Last post2012-09-19 08:58 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Linear combinations of Expectation of EmpiricalDistribution Bob Hanlon <hanlonr357@gmail.com> - 2012-09-19 08:58 +0000

#11816 — Re: Linear combinations of Expectation of EmpiricalDistribution

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-09-19 08:58 +0000
SubjectRe: Linear combinations of Expectation of EmpiricalDistribution
Message-ID<k3c1fa$f0a$1@smc.vnet.net>
Expectation[x,
 x \[Distributed] EmpiricalDistribution[{0, 1, 2}]]

1

Expectation[y,
 y \[Distributed] EmpiricalDistribution[{0, 10, 20}]]

10

Expectation[x + y,
 {x, y} \[Distributed] EmpiricalDistribution[
   Thread[{{0, 1, 2}, {0, 10, 20}}]]]

11

Expectation[a*x + b*y,
 {x, y} \[Distributed] EmpiricalDistribution[
   Thread[{{0, 1, 2}, {0, 10, 20}}]]]

a + 10 b


Bob Hanlon


On Tue, Sep 18, 2012 at 3:40 AM, Clemens Fruhwirth
<clemens@endorphin.org> wrote:
> Dear MathGroup,
>
> The expectation for any linear combination of random values is the
> linear combination of the respective expectations of the random
> values, such as
>
> E(aX+bY) = aE(X) + bE(Y)
>
> I wonder why Mathematica can't resolve this rule when
> EmpiricalDistributions come into play. For instance,
>
> Expectation[
>  x + y, {x \[Distributed] EmpiricalDistribution[{0, 1, 2}],
>   y \[Distributed] EmpiricalDistribution[{0, 10, 20}]}]
>
> I came up with:
>
> ExpectationX[
>   a_ + b_, {x_ \[Distributed] xdist_, y_ \[Distributed] ydist_}] :=
>  a + b //. {x -> Expectation[x, x \[Distributed] xdist],
>    y -> Expectation[y, y \[Distributed] ydist]}
>
> to resolve at least simple addition. But before I put more work into that:
>
> * Am I missing an assumption here or some syntax? Or is this rule just
> not built into Mathematica?
>
> * Is that in general the right approach to extend Mathematica?
>
> Thanks!
> --
> Fruhwirth Clemens http://clemens.endorphin.org
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web