Functions

/Users/garethloy/Musimathics/Musimat1.2/MusimatChapter9/C091704b.cpp File Reference

#include "MusimatChapter9.h"

Go to the source code of this file.

Functions

 MusimatChapter9Section (C091704b)
Real brownian (Real x, Real w, Real B)
Static Void PlotPoint (Real x, Real y)
Static Void para1 ()

Function Documentation

Real brownian ( Real  x,
Real  w,
Real  B 
)

Definition at line 13 of file C091704b.cpp.

                                     {
        Real R;
        Do {
                R = x + Random( -w, w );
        } While ( R > B Or R < -B );
        Return R;
}
MusimatChapter9Section ( C091704b   )

Definition at line 2 of file C091704b.cpp.

References para1().

                                 {
        Print("*** Brownian Nose Generator ***");
        /*****************************************************************************
         
         Brownian Nose Generator
         
         Here is a simple Brownian number generator (F. R. Moore 1990):
         *****************************************************************************/
        para1(); // Step into this function to continue.
}
Static Void para1 (  )

Definition at line 31 of file C091704b.cpp.

References brownian(), and PlotPoint().

                    {
        /*****************************************************************************
         Parameter x is either the initial value of the random walk or the value last calculated by brownian(). 
         Parameter w is called the window parameter because it determines the maximum amount by which 
         the value of x can change at one time. Parameter B is the bounds, limiting the Brownian motion 
         to within its range. This method departs from strict Brownian motion by retrying the random 
         choice until the new value lies within this range.
         
         We call the brownian() method each time we want a new Brownian number, passing it either 
         an initial value or the value of its previous output. For example, the following code generated the 
         function shown in figure 9.30.
         *****************************************************************************/
        
        Real x = 0.0;
        Real y = 0.0;
        
        For (Integer i = 0; i < 10; i = i + 1) {
                x = brownian(x, 0.5, 0.5);
                y = brownian(y, 0.5, 0.5);
                PlotPoint(x, y);        // plot a point on a graph at location [x, y]
        }
        
        /*****************************************************************************
         A Brownian noise signal and its power spectrum on a log-log plot are shown in figure 9.31. The 
         straight line in the figure traces the contour of 1/(f*f) for reference.
         *****************************************************************************/
}
Static Void PlotPoint ( Real  x,
Real  y 
)

Definition at line 21 of file C091704b.cpp.

{
        // Note, this function is a placeholder for the appropriate
        // graphics function call on your platform to plot a point
        //on a graph.
        
        RealList rL(x, y);
        Print(rL);
}