MathGroup Archive 2009

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

Search the Archive

Re: Sampling from a simplex: part 2

  • To: mathgroup at
  • Subject: [mg95904] Re: Sampling from a simplex: part 2
  • From: Andreas <aagas at>
  • Date: Thu, 29 Jan 2009 05:58:00 -0500 (EST)

The following from Wolfram Tech Support yields the same results as mine and simplifies the code:

sampleSimplex[sampleSize_, dimensions_, min_, max_] := 
 Module[{s, tableNormal},
  s = RandomReal[ExponentialDistribution[2], {sampleSize, dimensions}];
  Map[min + Normalize[#, Total]*(max - min) &, s]]

Can anyone confirm that this will indeed give me the kind of sample I need i.e. where min = -1 and max = 2?

Also, this still leaves me with the larger question of  approaches or rules of thumb to refactor Mathematica code (along the lines of Martin Fowler's book "Refactoring - Improving The Design of Existing Code" targeted predominately at object oriented languages) or simply to write the most concise, clear and robust code. 

Again, any suggestions, guidelines, or resource suggestions along these lines much appreciated.

  • Prev by Date: Re: Conditional list indexing
  • Next by Date: Re: Style Sheets in Version 7
  • Previous by thread: Sampling from a simplex: part 2
  • Next by thread: Mathematica having trouble with simple calculation...