4

I have a list of lists of fitted parameter values, e.g.

list={{a->1,b->10},{a->2,b->20},{a->3,b->30}}

(the actual parameter names can vary, as well as the size of the list)

What is the easiest way then to obtain the average parameter values, in this case avg={a->2,b->20} ?

2 Answers2

4
Normal@Merge[Mean][list]
(* {a -> 2, b -> 20} *)
kglr
  • 394,356
  • 18
  • 477
  • 896
1

A method that works on older versions of Mathematica is this:

{a, b} -> Map[Mean, Transpose[{a, b} /. list]]

but admittedly it won't be as fast as Merge.

C. E.
  • 70,533
  • 6
  • 140
  • 264