⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scauchy.cc

📁 c++编写的并行拉马克遗传算法的程序。实现分析对接程序
💻 CC
字号:
/* scauchy.cc *//***** RCS INFO **********************************************************$Id: scauchy.cc,v 3.0 1996/03/11 05:40:00 halliday Exp $$Source: /tmp_mnt/mgl/apps/src/autodock/3.0/autodock/RCS/scauchy.cc,v $$Log: scauchy.cc,v $// Revision 3.0  1996/03/11  05:40:00  halliday// The function definition for the GA/LS hybrid.//Revision 1.1  1993/02/05  15:42:11  whartInitial revision****** RCS INFO *********************************************************//* cauchy.c * * Code for generating deviates from the Cauchy/Lorentzian distribution. * * Comments regarding this code are included at the end of the file. * * Code suggested by Lester Ingber <ingber@alumni.caltech.edu> and *	Numerical Recipies in C by Press et. al. */#include <math.h>#include "ranlib.h"#define EPS     1.e-12float scauchy1(){float x, y; 			/* These four lines generate the tangent of a random			 *	angle;  this is equivalent to 			 *	y/x = tan(PI * ranf())			 */do {   x = 2.0 * ranf() - 1.0;   y = 2.0 * ranf() - 1.0;   } while (x * x + y * y > 1.0);if (fabs(x) < EPS)   x = (x < 0.0 ? x - EPS : x + EPS); return (y / x);}/*******Here's the summary of responses that I received concerning thegeneration of Cauchy deviates:Pretty much everyone who replied pointed out that the Cauchy distributioncan be generated by generating two standard normal deviates and takingtheir quotient:  N(0,1)/N(0,1).  Barrett P. Eynon <barry@playfair.stanford.edu>noted that the t distribution with 1 degree of freedom is equivalent tothe Cauchy distribution.  Finally, B. Narasimhan <naras@cda.mrs.umn.edu>noted that 	the ratio X/Y is Cauchy any time the pair (X,Y) is radially	distributed. See Devroye, "Non Uniform Random Variate	Generation", for more. Thus you can even use ratio of two	coordinates of a point generated uniformly in the unit disk in	2D.Code which uses this last observation was provided by Lester Ingber<ingber@umiacs.UMD.EDU> and is included at the end of this article.Mark Plutowski <pluto@cs.ucsd.edu> noted that the Cauchy distributionis also called the Lorentzian distribution, and is discussed as such inNumerical Recipies.  Both NR and Ping Chou <choup@cgrb.orst.edu> notedthat you can generate a Cauchy deviate by taking a uniform deviateon x \in [0,1] and computing tan(PI*x).  However, in NR they latercompute the Cauchy deviates using the same method used in Ingber's code,so presumably this is more efficient.Robert E George <regeorge@magnus.acs.ohio-state.edu> also noted thatthere is a routine in IMSL for generating Cauchy deviates.Thanks for everyone's replies!--Bill*****/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -