Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.mso.anu.edu.au/~fbriggs/WAARNEEM/gauss_test.mac
Дата изменения: Tue Sep 11 14:27:42 2001
Дата индексирования: Tue Oct 2 04:34:02 2012
Кодировка:

Поисковые слова: п п р р р р р р п п п п п п п п
noisedemo 2
#
# USAGE: in sm (supermongo)
# : macro read gauss_test.sm <<= loads macro into sm
# : noisedemo 1000 0 <<= runs macro with 1000 pts
# <<= 0 means no errorbars
define N $1
define DOERR $2
set x=1,$N
# dummy call to get ws dimensioned right
get_hist x v ws -.5 .5 .02
set ws=ws*0
erase
window 1 1 1 1

set y=x*0
limits 0 $N -.7 0.7
box
ptype 1 1
# generate a lot of points to uniformly cover -0.5 to 0.5
# -and- at the same time do averages of 10 samples => pseudo-gaussian
do i=1,10 {
set t=random($N)-0.5
set y=y+t
# keep plotting the uniform points
points x t
get_hist t v w -.5 .5 .02
set ws=ws+w
}
echo * Uniformly Distributed between -0.5 and 0.5 *
toplabel * Uniformly Distributed between -0.5 and 0.5 *
# use call to "cursor" in order to pause
cursor
# if( the cursor is far to the right) plot the "uniform" time series
# instead of continuing to compare with the pseudo-gassian points.
if($uxp > $N ) {
erase
connect x t
return}

# prepare and plot the pseudo gaussian points
set y=y/10
lweight 3
ctype red
points x y
ctype default
lweight 1
define ave (sum(y)/$N)
define rms (sqrt(sum(y*y)/$N))
define err ($rms/sqrt($N))
echo rms=sigma= $rms
echo average= $ave +- $err
echo
echo * red: averages of 10 random points *
# use call to "cursor" in order to pause
cursor
# if( cursor is far left ) stop
if($uxp < 0 ) {
return}

erase

limits v ws
box
hist v ws
set er=sqrt(ws)
if( $DOERR > 0 ) {
relocate -1 $($N/5)
draw 1 $($N/5)
error_y v ws er
}
ctype red
get_hist y v w -.5 .5 .02
hist v w
set er=sqrt(w)
if( $DOERR > 0 ) {
error_y v w er
}
ctype default
echo * Distribution of Random values and Dist of Averages (red) *

# use call to "cursor" in order to pause
cursor
# if( cursor is far left ) stop
if($uxp <-1 ) {
return}
# theoretical gaussian
set w=$N*exp(-0.5*(v/$rms)**2)*0.02/($rms*sqrt(2*3.1416))
connect v w
echo * added theoretical gaussian *

# use call to "cursor" in order to pause
cursor
# if( cursor is far left ) stop
if($uxp < -1 ) {
return}
# plot the times series of the gaussian
erase
limits x y
box
connect x y
echo * string of pseudo-gaussian noise *

cursor
if($uxp <-1 ) {
return}
erase
# compare the two types of time series
window 1 2 1 2
limits x t
connect x t
window 1 2 1 1
limits x y
connect x y
window 1 1 1 1
echo * comparison of Uniform Rand Nos and Gaussian noise *


cursor
if($uxp <-1 ) {
return}
erase
# do the FFTs of the times series and plot POWERS
set z=y*0
set y=y*100
set t=t*30
fft 1 y z r i
set y=r*r+i*i
set z=y*0
fft 1 t z r i
set t=r*r+i*i

window 1 2 1 2
limits 0 $($N/2) t
# limits x t
box 0 2 4 4
connect x t
window 1 2 1 1
limits 0 $($N/2) y
# limits x y
box 1 2 4 4
connect x y
window 1 1 1 1
echo * Ampl of Fourier Transforms of Unif. and Gaussian *

cursor
if($uxp <-1 ) {
return}
echo plot the complex values of the fourier coefficients
echo in order to illustrate the origin of Rayleigh distributed noise
echo distribution
erase
limits r i
set x=random($N)*6.2832
set rr=r*cos(x)+i*sin(x)
set ii=i*cos(x)-r*sin(x)
lweight 3
points rr ii
lweight 1
relocate -10 0
draw 10 0
relocate 0 -10
draw 0 10