Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Poisson random number generator

Status
Not open for further replies.

econ2008

Programmer
Jul 26, 2010
9
Hello everybody!

I started to learn Fortran 95/2003, because I want to program a model in the field of economics.
As far as I have understood, the random number generator in Fortran only calculates uniform distributed random numbers.
I know on the one hand that I can calculate any other distrubtion by applying the inverse function formula. But there should be any other possibility of calculating a poisson distributed random number.
Just to make it clear, I am not asking for a code, but for some helpful comments or tips where I can find an introduction to this topic. As I google I only find old codes (i.e. Fortran 77 or 90).
Does anyone know a good book or script, where the problems of generating random numbers in Fortran 95/2003 is dealt with? The books of Chapman, Brainerd or Metcalf were not very helpful on this specific topic. I am really desperate.

Thanks in advance

bjoern

 
Hi econ2008,

Welcome to the forums!

Are you specifically using the features of F2003? These include OOP features, and a number of other goodies. However, seeing as most compilers don't support the full F2003 set, I'd stay away from it until they do.

F90 and F95 are very similar; there are some improvements (forall, where, etc. statements), but it was a minor revision.

F90 will integrate seamlessly into F95, so if you have code for that in F90, you should be able to use it without a problem. I think that something as simple as a random number generator should work without a problem.

If you run into problems, just post here, and someone will almost certainly be able to help you.

--------------------------------------
Background: Chemical engineer, familiar mostly with MATLAB, but now branching out into real programming.
 
Basically, as far as arithmetic syntax is concerned, there is no difference in all the versions of Fortran: from Fortran I to Fortran 2003. The only difference is that FI to F77 expect 6 spaces before the statement, F90 onwards is free format. If your Poisson distribution has something like
Code:
      real function Poisson
      ...
      Poisson = ....
      end
All you need to do is change the end to end function and that's it. It should compile in F90/95.
 
Hey!

First of all thank you for your fast answers! It seems I first have to learn a bit more about the basics in Fortran.
Especially about subroutines, functions and modules.
Thank you, and I will post a thread when I run into new problems (and I know that I will!).

econ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top