I am trying to generate datasets for which specific conditions related to the grand mean, group means, and differences among these values hold. I had tried in R, but was hoping that using Mathematica summation notation and Reduce[] would give more explicit outputs, versus my guess-and-check in R.

For example, for a polynomial of four additive terms: x^4 + 6*x^2*y^2 + 4*x*y^3 + y^4, (A+B+C+D), I want to generate a dataset with 10 groups of 100 individuals each, such that the third term predominates. I had done Reduce[C/A > 1 & C/B > 1 & C/D > 1] to get general conditions on x and y. However, as I mentioned, the terms are actually sums, and the third and fourth terms are, respectively, for example:

$4 \sum_{i=1}^k \sum_{j=1}^{n_{i}} (\overline{y_{i \bullet}} - \overline{y_{\bullet \bullet}}) (y_{ij} - \overline{y_{i \bullet}})^3$


$\sum_{i=1}^k \sum_{j=1}^{n_{i}} (y_{ij} - \overline{y_{i \bullet}})^4$

where $y_{ij}$ is individual $i$ in group $j$, $\overline{y_{\bullet \bullet}}$ is the grand mean, and $\overline{y_{i \bullet}}$ is the mean of a group. I'd like to make use of this summation notation to output a set of values that satisfy the condition that the third term predominates. For example, C/D > 1:

Reduce[$\frac{4 \sum_{i=1}^k \sum_{j=1}^{n_{i}} (\overline{y_{i \bullet}} - \overline{y_{\bullet \bullet}}) (y_{ij} - \overline{y_{i \bullet}})^3}{\sum_{i=1}^k \sum_{j=1}^{n_{i}} (y_{ij} - \overline{y_{i \bullet}})^4} > 1$]

but generating a list of $i$ values that satisfy the condition. Is there syntax for this kind of Reduce[], and data generation, in Mathematica? I am not familiar with how to transform the dot notation into something interpretable by Mathematica.



1 Answer 1


Only for the "dot" and summation notation: If you have Y = Array[y, {10, 100}]; then the list of group means $(y_{1,\bullet},\dotsc,y_{k,\bullet})$ can be obtained by

groupmeans = Mean /@ Y


mean = Mean[groupmeans]

as well as Mean[Mean[Y]] equals the overall mean.

$4 \sum_{i=1}^k \sum_{j=1}^{n_{i}} (\overline{y_{i \bullet}} - \overline{y_{\bullet \bullet}}) (y_{ij} - \overline{y_{i \bullet}})^3$

Can be expressed as

c = 4 (groupmeans - mean).Total[(Y - groupmeans^3), {2}]


$\sum_{i=1}^k \sum_{j=1}^{n_{i}} (y_{ij} - \overline{y_{i \bullet}})^4$ is obtained by

d = Total[(Y - Mean[Mean[Y]])^4, {2}]

But I don't know what you want to do with Reduce. With so many unknowns, you are bound to make yourself unhappy. FindInstance might be more helpful. A possible syntax would be

FindInstance[c > d, Flatten[Y]]

but I did not wait for an answer to be returned.

  • 1
    $\begingroup$ I was using Reduce to find the general conditions on x and y for which C/D & C/B & C/A. The only constraints I have been thinking of for the $i$ would be that they are positive and real. Very interesting about the FindInstance syntax. I assume it could work then as FindInstance[c>d && c>a && c>b, Flatten[Y], Reals], assuming $a$ and $b$ are also formulated as you suggest, above. I will try this on my computer that has Mathematica. Thanks very much for these suggestions. $\endgroup$
    – J.D.
    Oct 24, 2018 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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