282214147 Amsub – bli-ftbm The Amoeba Routines and their visualization are in for\AMSUB.ZIP for\BLIFTBM.ZIP cpp\AMSUB.ZIP cpp\BLIFTBM.ZIP Error estimation in principle is in ../class2K/optimization/amoeba/Errinfun.htm The random distributions are reproduced below. 1/2 iy, pulling a value from a randomly selected table entry and replacing that with a new value. This can be re-initialized by printing out ix and iy and then calling rseed. This wastes 128 random numbers, but gives a completely determined new set of random numbers. Gaussian distribution3 Rgauss=-6; For(i=0;i<12;++i){Rgauss+=rndmf();} 1 1 f xdx 0 2 1 1 f 2 x 2 dx 0 3 Psuedo Random numbers Random numbers are not wanted. What is desired is a set of completely reproducible numbers that are the same on all computers and in both C and Fortran. In addition, it must be true that the numbers give all averages the same as would be given by actual random numbers. In practice the numbers should be re-initialized with the numbers needed to recreate the desired set written out as 17894561 3678991 18345899 234567899 ... In this way, when the code bombs after 23 hours of running, the situation just before the bomb can be recreated by simply entering these numbers. With this many random numbers, the "randomness" of the set can be a problem for some calculations1. The method used here, first suggested by MacLaren and Marsaglia2, is to insert numbers into a table with a multiplicative congruential method with one multiplier and seed and to extract them from the table with a multiplicative congruential method with a different multiplier and seed. random.for contains the common COMMON/RAN/IX,IY,ITAB(128) RANDOM.CPP RANDOM.H The file random.h contains struct {int ix,iy,itab[128];} ran; int rseed(int ix,int iy); double rndmf(); z z Equation 1 Thus 2 f 2 f 2 1 1 1 3 4 12 Equation 2 or 12 12 f 6 rndmf i 1 bg 6 1 Equation 3 This means that the above sum is 0 +- 1. If I want to produce a peak of height P = 36 +- beta with a Gaussian distribution of beta. I simply take 12 P 36 beta * 6 rndmf i 1 Equation 4 This is implemented in ..\ArtDat\for\FUNWE.ZIP and ..\ArtDat\cpp\FUNWE.ZIP The seeds are ix and iy. The random number set is initialized by calling rseed(ix,iy). This call causes 128 numbers to be fed into the table itab[128] with one random number generator. The call x=rndmf() gives a random number base on ix,iy and itab, between 0 and 1. It selects this by advancing ix and Figure 1 Black is Fortran, Blue is C 1 R. L. Coldwell, "Correlational Defects in the Standard IBM 360 Random Number Generator and the Classical Ideal Gas Correlation Function", J. Computational Phys. 14, 223 (1974). 2 M. D. MacLaren and G. Marsaglia, J. Assoc. Comput. Mach. 12 (1965),83 3 J. M Hammersley and D. C. Handscomb, Monte Carlo Methods, John Wiley (1964) p.39 282214147 2/2 completed assignments or four + the hello code earn an A. Do as many as you like, but leave time for your other homework. – Good Luck! Assignment 05-3 Figure 2 Funwe. Assignment 05-4 Zips For 01/31/2005 TLORENT.ZIP appears in Feb1.htm - Feb3.htm - Feb10.htm (Assign03_02 01/31/2005 TLOCATE.ZIP appears in Feb1.htm - Feb3.htm 02/09/2005 LAGRANGE.ZIP Feb3.htm - Feb8.htm - Feb10.htm Assign03_02 02/23/2005 02/23/2005 02/23/2005 1. Change funwe to generate a two bump Gaussian with error – one extra line in the file. 2. Modify ftbm2 in AMSUB to read the file produced by funwe on the first pass then to calculate a CHI = I ((fI-fA(xI;cons))/errI)2 with fA(xI;cons) – the same function as in 1. 3. Use the code in BLIFTBM to make a file of the fit. Plot the fit and the “data” – note the E and e as symbols in gplot produce error bars. 4. Find the limits – vary the spacing between the bumps and the errors until the Amoeba cannot, even with coaxing find the peaks. AMSUB.ZIP - here BLIFTBM.ZIP- here FUNWE.ZIP- here Cpp 02/01/2005 TLOCATE.ZIP Feb1.htm - Feb3.htm 02/08/2005 CTLAG.ZIP Feb8.htm - Feb10.htm Assign03_02 Feb17.htm 02/17/2005 CLOREN.ZIP Feb17.htm 02/17/2005 TSPLINE.ZIP Feb17.htm 02/17/2005 TSPLINE2.ZIP Feb17.htm 02/23/2005 AMSUB.ZIP - here 02/23/2005 BLIFTBM.ZIP - here 02/23/2005 FUNWE.ZIP – here Assignments You are welcome to do any of the assignments in ..\class2K\Homework\Homework3.htm. Five This is the same as the assignment above, except in step 2, the fA(xI,cons) is a small set of values of xbar and ybar. That is fA(xI;cons) is a cubic Lagrange interpolating the values xbar and ybar. 1. Set a reasonable grid of xbar values and let the cons be the ybar values on this grid. 2. Let both xbar and ybar be free constants. Note the need to resort the xbar values to keep them in ascending order before calculating chi. Assignment 05-5 This is the same as the assignment above, except that fA(xI;cons) is a spline interpolating the values xbar and ybar. 1. Set a reasonable grid of xbar values and let the cons be the ybar values on this grid. 2. Let both xbar and ybar be free constants. Note the need to resort the xbar values to keep them in ascending order before calculating chi. 3. Note that spline needs to be called before splint.