2
$\begingroup$

I would like to define the following variable :

enter image description here

So the average value (a) takes for every "individual" but i.

But actually, for each i, the value (a) takes depends on the preceding average:

enter image description here

Finally, I would like to compute the following sum :

enter image description here

I don't have a very large culture in Wolfram, but I have tried all I could without succeeding. Could someone help me please ? I hope my request is clear enough.

Best,

Peter

$\endgroup$
  • $\begingroup$ What are $f$ and $g$? You might have to solve a system of nonlinear equations in order to obtain the $a_i$ and $\hat a_{-i}$. And that will be impossible without known at leas $g$. $\endgroup$ – Henrik Schumacher Aug 31 '18 at 15:30
  • $\begingroup$ Tanks for your answer. I know both $f$ and $g$ but they but as they are quite complex I though it was not necassary to put their explicit expression. Here they are : $\endgroup$ – Peter Aug 31 '18 at 17:27
  • $\begingroup$ $\frac{\big(-3A^{2}+2A^{2}\hat{a}_{-i}+16w_{0}^{2}(A+1-2\hat{a}_{-i})\big)+\theta_{i}\big((8\hat{a}_{-i}-12-32w_{0}^{2})A+(6-4\hat{a}_{-i}-8x\hat{a}_{-i})A^{2}+x\big((12-16\hat{a}_{-i}+32w_{0}^{2})A+(8\hat{a}_{-i}-6)\big)}{\big(32A+2A^{2}-32-160w_{0}^{2})+\theta_{i}\big(16A-A^{2}(-8-16x)\big)+x\big(-16A-8A^{2}\big)}$ = $a_{i}$ $\endgroup$ – Peter Aug 31 '18 at 17:39
  • $\begingroup$ Then I would want to compute : $\bigg(\sum_{i=1}^{n}w_{0}\big(\frac{1}{2}+R_{i}(a_{i};e_{i})\big)^{2}\bigg)$ with $R_{i}(a_{i};e_{i})=\frac{\phi(a_{i}-\hat{a}_{-i})+\beta e_{i}}{1-p}$ $\endgroup$ – Peter Aug 31 '18 at 17:43
  • 1
    $\begingroup$ Peter, it would help if you add these formulas in Mathematica syntax to your question. (You find a link called "edit" right below your question. Moreover, many new undeclared symbols popped up in your new formula. Please, get into the habit to give complete information. If you don't do your part, why should anyone bother to figure out what you mean? $\endgroup$ – Henrik Schumacher Aug 31 '18 at 17:49
2
$\begingroup$

To define $\hat{a}_i$ you can use:

ahat1[lst_, i_] := Mean[Drop[lst, {i}]]

lst = Array[Subscript[a, #] &, 10];
ahat1[lst, 4]

$\frac{1}{9} \left(a_1+a_2+a_3+a_5+a_6+a_7+a_8+a_9+a_{10}\right)$

Faster alternatives:

ahat2[lst_, i_] := With[{l = Length[lst] - 1},  Subtract[Total[lst], lst[[i]]]/ l] 
ahat3[lst_, i_] := With[{l = Length[lst] - 1}, (1 + 1/l) Mean[lst] - lst[[i]]/l]

Timings:

ll = RandomInteger[10000, 1000000];
ahat1[ll, 3] // RepeatedTiming

{0.0030, 4996512583/999999}

ahat2[ll, 3] // RepeatedTiming 

{0.00164, 4996512583/999999}

ahat3[ll, 3] // RepeatedTiming 

{0.00163, 4996512583/999999}

$\endgroup$
  • $\begingroup$ Thanks a lot for this answer, it will help me a lot ! I will use the "ahat2 way". $\endgroup$ – Peter Aug 31 '18 at 17:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.