# A question about the use of Sum

Suppose I have the following formula. It calculates the average value of $$n$$ evenly spaces numbers on the range from $$L$$ to $$H$$.

1/n Sum[x, {x, L, H, (H - L)/(n - 1)}]


My question is, how can I use Mathematica to compute the average value of the above, when I remove a specific number from the sequence. I am looking for an elegant solution, perhaps one that removes a particular index, or some other method I have not thought about.

Ideally, the solution should allow me to plot the average of the numbers on the Y-axis, and the removed index on the X-axis.

Probably easiest to just manage this as a list:

list[l_, h_, n_] := Table[x, {x, l, h, (h-l)/(n-1)}];
ListPlot[Table[Mean[Drop[list[1, 10, 10], {i}]], {i, 1, 10}]


If you really want to do this with sums, it'd be possible to modify the formula slightly by subtracting off the missing term:

1/(n - 1) (Sum[x, {x, l, h, (h - l)/(n - 1)}] - ((h - l)/(n - 1) i + l))


(-l - (i (h - l))/(-1 + n) + (Floor[n] (-h - l + 2 l n + h Floor[n] - l Floor[n]))/(2 (-1 + n)))/(-1 + n)

Plotting this for h->10, l->1, and n->10, over {i, 0, 9, 1} provides the same plot as previously shown.

The maths is very simple. For any list ls

ls = Range[1, 19];
m = Mean[ls]
(* 10 *)


we can "downdate" our estimate of the mean

x = 15;
Mean[Complement[ls, {x}]] == Module[{n = Length[ls]}, (n m - x)/(n - 1)]
(* True *)

ClearAll[f]
f[n_, l_, h_] := Module[{r = Subdivide[l, h, n - 1]},
MapIndexed[{#, Mean[Drop[r, #2]]} &, r]]

ListPlot[Callout[#, {##}]& /@ f[6, 11, 21]]