Unexpected behavior in function definitions with vector arguments (Wolfram)

52 Views Asked by At

I have the following functions defined in Mathematica.

Posterior calculation given a realization of a signal (or experiment, as they are called outside of economics):

posterior[prior_, signal_, real_] := Table[prior[[i]]*signal[[i,real]], {i, 3}]/Sum[prior[[i]]*signal[[i,real]], {i, 3}]

A Bernoulli utility that amounts to rewarding correct guesses of the state -

utility[guess_, states_, state_] := -(guess . states - states[[state]])^2

A conditional expected utility given a prior and a signal (yes, Bernoulli utility should be an argument here too, but bear with me) -

ExpU[prior_, signal_, states_] := Sum[prior[[j]]*Sum[utility[posterior[prior, signal, k], states, j]*signal[[j,k]]*posterior[prior, signal, k], {k, 3}], {j, 3}]

I'm encountering two very odd problems. The first is that uninformative signals change the prior -

prior1 = {0.2, 0.6, 0.8}

signalUninformative = {{1/3, 1/3, 1/3}, {1/3, 1/3, 1/3}, {1/3, 1/3, 1/3}}

In[79]:= posterior[prior1, signalUninformative, 1]

Out[79]= {0.125, 0.375, 0.5}

Moreover, despite being apparently erroneous, the end result does not depend on which signal is realized; it's always the same output (Out(79)).

The second problem is that ExpU somehow delivers a vector as an answer.

In[98]:= signalUninformative = {{1/3, 1/3, 1/3}, {1/3, 1/3, 1/3}, {1/3, 1/3, 1/3}}

ExpU[{0.1, 0.9, 0.1}, signalUninformative, states1]

Out[98]= {{1/3, 1/3, 1/3}, {1/3, 1/3, 1/3}, {1/3, 1/3, 1/3}}

Out[99]= {-0.0181818, -0.163636, -0.0181818}

QUESTION: Am I misunderstanding Wolfram vector syntax, Sum function, Table function or is something wrong with my definition of the Bayes' rule computation?

CONCISE MATHEMATICAL EXPLANATION: I'm trying to use Wolfram's graphing capabilities to explore some hunches about behavior of expected utilities conditional on information, that is, given a state space $\Theta$ and a measure space $X = (\mathcal{X}; P_{\theta \in \Theta})$, how does the following function change with the prior (designated $\mu$) -

$U(\mu, X) \equiv \int_\Theta \int_\mathcal{X} \max_a \int_\Theta u(a, \theta) d \mu(\theta|x) d P_\theta (x) d \mu(\theta)$