Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Scientific Programming Question

  1. Mar 29, 2007 #1
    Hello, I'm new to these forums, so please forgive any problems with my post. In particular, I wasn't sure where to put this post.

    I'm working on a scientific programming problem in Java, and I don't have a huge amount of familiarity with either scientific programming or Java, so you can imagine my dilemma. I'm trying to generate a random distribution of doubles following a truncated power law distribution. That is, I want to generate a list of times, T, for which the probability distribution P(T) is proportional to:


    where A and B are constants.

    Does anyone have any thoughts on how I would go about this? I'm open to programming it myself, if someone can suggest how to get started, or of course if such a distribution is already implemented in some publicly available scientific programming library that would be even better. If writing it myself, I figured I would create a TruncatedPowerLaw class extending the Random class, with a method for nextTruncatedPowerLaw, but I really have no idea where to go from there (i.e., the hard stuff). Thanks in advance!

    By the way, if someone sees a way to accomplish this easily in another language, I'm not completely averse to that, although Java is preferred.
  2. jcsd
  3. Mar 30, 2007 #2
    If you don't mind programming in C or C++, you could use the GNU Scientific Library. It has random number generators for a lot of distributions.
    There is a Java interface to it, but I don't know if it covers the entire library.
  4. Mar 30, 2007 #3
    You can also try the Numerical Recipes book Chpt. 7 (It's available for free online). It might have an algorithm for your problem though you'll probably have to program the solution yourself.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook