TAILIEUCHUNG - Random Numbers part 5

if (n != nold) { If n has changed, then compute useful quantien=n; ties. oldg=gammln(en+); nold=n; } if (p != pold) { If p has changed, then compute useful quantipc=; ties. plog=log(p); pclog=log(pc); pold=p; } sq=sqrt(*am*pc) | 296 Chapter 7. Random Numbers if n nold en n oldg gammln en nold n if p pold pc plog log p pclog log pc pold p sq sqrt am pc do do angle PI ran1 idum y tan angle If n has changed then compute useful quantities. If p has changed then compute useful quantities. The following code should by now seem familiar rejection method with a Lorentzian comparison function. em sq y am while em em en Reject. em floor em Trick for integer-valued distribution. t sq y y exp oldg-gammln em -gammln en-em em plog en-em pclog while ran1 idum t Reject. This happens about times per devi- bnl em if p pp bnl n-bnl return bnl ate on average. Remember to undo the symmetry transformation. See Devroye 2 and Bratley 3 for many additional algorithms. CITED REFERENCES AND FURTHER READING Knuth . 1981 SeminumericalAlgorithms 2nd ed. vol. 2 of TheArtofComputerProgramming Reading MA Addison-Wesley pp. 120ff. 1 Devroye L. 1986 Non-Uniform Random Variate Generation New York Springer-Verlag . 2 Bratley P. Fox . and Schrage . 1983 A Guide to Simulation New York SpringerVerlag . 3 . Generation of Random Bits The C language gives you useful access to some machine-level bitwise operations such as left shift . This section will show you how to put such abilities to good use. The problem is how to generate single random bits with 0 and 1 equally probable. Of course you can just generate uniform random deviates between zero and one and use their high-order bit . test if they are greater than or less than . However this takes a lot of arithmetic there are special-purpose applications such as real-time signal processing where you want to generate bits very much faster than that. One method for generating random bits with two variant implementations is based on primitive polynomials modulo 2. The theory of these polynomials is beyond our scope although and will give you small tastes of it . Here Sample page from NUMERICAL RECIPES IN C THE .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.