MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

stirring chocolate pudding backwards: identifying coordinates

Some background to start, which I'll follow with two questions:

The following function samples sets of coordinates from a multi-dimensional simplex:

    sampleSimplex[sampleSize_, dimensions_] := Normalize[#, Total](*)*)& /@ RandomReal[ExponentialDistribution[2], {sampleSize, dimensions}]

Each set of coordinates (sub-lists in the output) totals 1.  The following graphs the coordinates so you can
see what the code does:

    Graphics3D[Point /@ sampleSimplex[1000, 3, 0, 1], ImageSize -> 250, ViewPoint -> {Pi, Pi/2, 2}]

To keep things simple let's generate 4 sets of coordinates, each with 3 dimensions:

    samples = sampleSimplex[4, 3] 


Again note: each sub-list totals 1.  Also in an actual application I would take many more samples from the simplex.

Next, I generate time series data for just 3 intervals with the same dimensionality as the above:

    values = RandomReal[{.08, 1.2}, {3, 3}] 


The next function calculates a weighted average of all the sets of coordinates, with the weights in proportion to the corresponding time series values.  Note: each sub-list of values corresponds to a single time interval whereas the following function will average the values of the entire set of sub-lists in the list "samples" at each time interval.

    weightedAverage[values_, samples_] := Mean[(t = #; 1 + Inner[Times, t, # - 1, Plus] & /@ values) & /@ samples] 

    weightedAverages = weightedAverage[values, samples]


A bunch of people of this board have helped me get this far.  So far so good.  Many thanks to all of you.

Next I need to determine 2 things.  I need to identify the specific coordinates 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 surface 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 might 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 pudding backwards and hoping to get back to the original ingredients.       

Any help much appreciated, I hope everyone hasn't disappeared for the summer.


  • Prev by Date: Re: Re: Re: Putting an If in my function
  • Next by Date: Re: Re: Ansatz?
  • Previous by thread: TSV files as a list of list of lists?
  • Next by thread: Re: stirring chocolate pudding backwards: identifying coordinates