Re: stirring chocolate pudding backwards: identifying coordinates

*To*: mathgroup at smc.vnet.net*Subject*: [mg101291] Re: stirring chocolate pudding backwards: identifying coordinates*From*: Ray Koopman <koopman at sfu.ca>*Date*: Tue, 30 Jun 2009 06:33:43 -0400 (EDT)*References*: <h1vm4s$abq$1@smc.vnet.net>

samples = { {.375153, .412505, .212342}, {.470678, .360788, .168533}, {.0510186, .828575, .120407}, {.24481, .00851303, .746677}}; values = { {.518072, .490701, .813364}, {.404083, .356724, .362498}, {.507292, .436016, .247148}}; values.Mean[samples] {0.599181, 0.372042, 0.397434} which are the same as your weightedAverages. The answer to your second question is that the point associated with the weighted average value is always the average sample point. The answer to your first question -- the point asssociated with the highest value at each interval -- is a little more complicated. We have values.Transpose@samples {{0.569484, 0.557963, 0.530949, 0.738327}, {0.375717, 0.379988, 0.359836, 0.372629}, {0.422651, 0.437733, 0.416912, 0.312442}} so the indices of the maximizing points are given by Flatten[Ordering[samples.#,-1]& /@ values] {4, 2, 2} On Jun 25, 4:13 am, Andreas <aa... at ix.netcom.com> wrote: > Some background to start, which I'll follow with two questions: > > The following function samples sets of coordinates from a multi-dimension= al simplex: > > sampleSimplex[sampleSize_, dimensions_] := Normalize[#, Total](*)*)= & /@ RandomReal[ExponentialDistribution[2], {sampleSize, dimensions}] > > Each set of coordinates (sub-lists in the output) totals 1. The followin= g graphs the coordinates so you can > see what the code does: > > Graphics3D[Point /@ sampleSimplex[1000, 3, 0, 1], ImageSize -> 250, V= iewPoint -> {Pi, Pi/2, 2}] > > To keep things simple let's generate 4 sets of coordinates, each with 3 d= imensions: > > samples = sampleSimplex[4, 3] > > { > {0.375153,0.412505,0.212342}, > {0.470678,0.360788,0.168533}, > {0.0510186,0.828575,0.120407}, > {0.24481,0.00851303,0.746677} > } > > Again note: each sub-list totals 1. Also in an actual application I woul= d take many more samples from the simplex. > > Next, I generate time series data for just 3 intervals with the same dime= nsionality as the above: > > values = RandomReal[{.08, 1.2}, {3, 3}] > > { > {0.518072,0.490701,0.813364}, > {0.404083,0.356724,0.362498}, > {0.507292,0.436016,0.247148}, > } > > The next function calculates a weighted average of all the sets of coordi= nates, with the weights in proportion to the corresponding time series valu= es. Note: each sub-list of values corresponds to a single time interval wh= ereas the following function will average the values of the entire set of s= ub-lists in the list "samples" at each time interval. > > weightedAverage[values_, samples_] := Mean[(t = #; 1 + Inner[Time= s, t, # - 1, Plus] & /@ values) & /@ samples] > > weightedAverages = weightedAverage[values, samples] > > { > 0.599181 > 0.372042 > 0.397434 > } > > A bunch of people of this board have helped me get this far. So far so g= ood. Many thanks to all of you. > > Next I need to determine 2 things. I need to identify the specific coord= inates associated with: > > 1. the weighted average value at each interval and > 2. the highest value at each interval. > > To help clarify this (I hope), I think of the triangular surface depicted= in the Graphics3D[] above and imagine a value axis extending perpendicular= to it. This represents a single time interval. I picture that the > > weightedAverage[] function calculates a value for each point on the surfa= ce hovering above the samples triangle. It then averages them. So one can= imagine a second surface hovering above the first representing the values = associated with each point of the first. > > So, again I need to identify the point associated with the highest value = at each interval (this could only come > from the highest values point from the list, "samples") and similarly the= point associated with the weighted average value (this might or might not = be a point within the list, "samples" because the weighted average value mi= ght fall at a point between the samples). > > Not certain how to approach a solution. From the functional programming = constructs I've used so far it seems a little like stirring chocolate puddi= ng backwards and hoping to get back to the original ingredients. > > Any help much appreciated, I hope everyone hasn't disappeared for the sum= mer. > > Thanks, > A

**Re: Re: Wolfram | Alpha: Acres per square mile? (oddities)**

**stirring chocolate pudding backwards: identifying coordinates**

**Re: Wolfram | Alpha: Acres per square mile? (oddities)**