Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The C version is below: #include float expdev(long *idum) /*Returns an exponentially distributed, positive, random deviate of unit mean, using ran1(idum) as the source of
The C version is below:
#include
float expdev(long *idum)
/*Returns an exponentially distributed, positive, random deviate of unit mean, using
ran1(idum) as the source of uniform deviates.*/
{
float ran1(long *idum);
float dum;
do
dum=ran1(idum);
while (dum == 0.0);
return -log(dum);
}
The FORTRAN version is here :
FUNCTION expdev(idum)
!USES ran1
!Returns an exponentially distributed, positive, random deviate of unit mean, using
!ran1(idum) as the source of uniform deviates.
INTEGER idum
REAL expdev
REAL dum,ran1
1 dum=ran1(idum)
if(dum.eq.0.) goto 1 ! so that random number is set to differ than 0 !
expdev=-log(dum)
return
END
Please use these codes and also ran1.f90 and ran1.c (which we compiled and executed in the class) functions, and generate 10 random number for the seed matrix below :
int nuvem[11]={-9,1,2,9,16,25,36,49,64,3,-11}; //for C
integer d(10)
DATA d/1,2,9,16,25,36,49,64,3,-11 ! For FORTRAN
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started