📄 gauss.c
字号:
/*| This material contains proprietary software of Entropic Processing, Inc.| Any reproduction, distribution, or publication without the the prior| written permission of Entropic Processing, Inc. is strictly prohibited.| Any public distribution of copies of this work authorized in writing by| Entropic Processing, Inc. must bear the notice|| "Copyright 1986 Entropic Processing, Inc."|| Written by: S. Shankar Narayan|| Module: gauss.c| */#ifdef SCCSstatic char *sccs_id = "@(#)gauss.c 1.2 4/21/86 (gauss.c)";#endiffloat gauss(dummy) /* gaussian random number generation */float dummy;{ extern float rand(); double sqrt(),log(); static int flag = 1; double s,v1,v2; static double x1,x2; if (flag == 2) { flag = 1; return(x1);} do { v1 = 2.0*rand(dummy); v2 = 2.0*rand(dummy); s = v1*v1+v2*v2; } while (s > 1.0); x1 = sqrt(-2.0*log(s)/s); x2 = v2*x1; x1 = v1*x1; flag = 2; return (x2);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -