       A Mathematica Puzzle Involving Computation of Expected Utilities

• To: mathgroup at christensen.cybernetics.net
• Subject: [mg804] A Mathematica Puzzle Involving Computation of Expected Utilities
• From: SChandler at uh.edu (Seth Chandler)
• Date: Fri, 21 Apr 1995 01:43:25 -0400

```Suppose you have m functions

In
funcs=Array[f,4]

Out
{f, f, f, f}

and you want to associate them with a list with n elements

In
probs=Array[p,5]

Out
{p, p, p, p, p}

and an m x n array that looks something like this.

In  states=Array[s,{4,5}]

Out
{{s[1, 1], s[1, 2], s[1, 3], s[1, 4], s[1, 5]},
{s[2, 1], s[2, 2], s[2, 3], s[2, 4], s[2, 5]},
{s[3, 1], s[3, 2], s[3, 3], s[3, 4], s[3, 5]},
{s[4, 1], s[4, 2], s[4, 3], s[4, 4], s[4, 5]}}

so that you end up with the following output

{p f[s[1, 1]] + p f[s[1, 2]] +
p f[s[1, 3]] + p f[s[1, 4]] +
p f[s[1, 5]],
p f[s[2, 1]] + p f[s[2, 2]] +
p f[s[2, 3]] + p f[s[2, 4]] +
p f[s[2, 5]],
p f[s[3, 1]] + p f[s[3, 2]] +
p f[s[3, 3]] + p f[s[3, 4]] +
p f[s[3, 5]],
p f[s[4, 1]] + p f[s[4, 2]] +
p f[s[4, 3]] + p f[s[4, 4]] +
p f[s[4, 5]]}

The best procedure I have come up with is as follows:

(states*funcs).pr/.Times[a_,b_,c_]->b*a[c]

But I'm willing to bet there's a better and more elegant way.  Plus, this
method does not work when the functions are not abstractions like f, but
actual pure functions like, say, Function[x,-Exp[-x]].

Does anyone have a suggestion?

P.S. This would be useful in determining the expected utilities of n players
in a game that can end up in m states.

==================================
Professor Seth J. Chandler
University of Houston Law Center
BLB132
Houston, Texas 77204
SChandler at uh.edu

```

• Prev by Date: Re: Running Mathematica in Windows 95
• Next by Date: Programming Options for Power Expand
• Previous by thread: Plotting waves
• Next by thread: Re: A Mathematica Puzzle Involving Computation of Expected Utilities