I am trying to model what is called the extreme spread of a series of shots at a target. Each shot is from a normal distribution with mean 0 and variance 1. For this example there are three shots per group and I have four groups to analyze.
The computation of the extreme spread is simply the maximum Euclidean distance between the shots, so I need to compute all of the Euclidean distances between the three shots per group. Then find the maximum distance for each group.
The following code attempts to do that except the last step (the do loop) doesn't work. I'm new to Mathematica, so I'm not even sure my syntax is correct - except that Mathematica doesn't return an error.
Clear["Global`*"]
μ = 0
σ = 1
RandomSeed[66936, Method -> All];
\[ScriptCapitalD] = NormalDistribution[μ, σ];
rv := RandomVariate[\[ScriptCapitalD]];
shotsPerGroup = 3
iterations = 4
data = Flatten[Table[List[i, rv], {i, 1, iterations}, {j, 1, shotsPerGroup}], 1];
groupBy = GatherBy[data, First][[All, All, 2]];
edist = {}
Do[
Append[edist, EuclideanDistance[groupBy[[i, j]], groupBy[[i, k]]]],
{i, 1, iterations},
{j, i, shotsPerGroup - 1},
{k, j + 1, shotsPerGroup}
]
edist
AppendTo. – Patrick Stevens Sep 22 '15 at 16:45