INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

rand.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics 
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2004-2009 Alex Brooks, Alexei Makarenko, Tobias Kaupp
00005  *
00006  * This distribution is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 #ifndef HYDROUTIL_NRAND__H
00011 #define HYDROUTIL_NRAND__H
00012 
00013 #include <cmath>
00014 
00015 //
00016 // General-purpose random number utilities
00017 //
00018 // Author: Alex Brooks
00019 //
00020 
00021 namespace hydroutil {
00022 
00023     // Fuck you, windows.
00024     // const double INV_SQRT_TWO_PI = 1/sqrt(2*M_PI);
00025     const double INV_SQRT_TWO_PI = (double)(1.0/std::sqrt(2*3.14159265358979));
00026 
00028     inline double G( double dist, double sd )
00029     { return (double)( (INV_SQRT_TWO_PI/sd) * std::exp( -(dist*dist)/(2.0*sd*sd) ) ); }
00030 
00032     inline double GCov( double dist, double cov )
00033     { return (double)( (INV_SQRT_TWO_PI/std::sqrt(cov)) * std::exp( -(dist*dist)/(2.0*cov) ) ); }
00034 
00037     inline double multiG( double xDiff, double yDiff, double xx, double yy )
00038     { return G(xDiff,std::sqrt(xx)) * G(yDiff,std::sqrt(yy)); }
00039 
00041     double normalRand( double mean, double std );
00042 
00044     double randNum( double minVal, double maxVal );
00045 
00047     double randNumInclusive( double minVal, double maxVal );
00048 }
00049 
00050 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5