source: cpp/frams/util/rndutil.h @ 1299

Last change on this file since 1299 was 793, checked in by Maciej Komosinski, 6 years ago

Code formatting

  • Property svn:eol-style set to native
File size: 1.0 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5#ifndef _RNDUTIL_H_
6#define _RNDUTIL_H_
7
8#include <common/nonstd.h>
9#include "math.h"
10
11/** @file rndutil.h various functions */
12
13/** @param x change seed if x<=0
14        @return random value [0..x-1] if x>0 */
15unsigned short pseudornd(short x);
16
17double CustomRnd(double*);
18// the parameter is a table which describes the random distribution:
19// e.g.
20// double x[]={ 3,     // 3 intervals
21//  -10,-1,            // (each of them has always uniform distribution and equal probability of being selected)
22//  -1, 1,
23//   1,10, };
24
25class RandomGener
26{
27public:
28        RandomGener() { isNextGauss = 0; }
29        static double Uni(double begin, double end); ///< uniform excluding 'end' boundary
30        double GaussStd();
31        double Gauss(double m, double s); ///< usually will not return further than 5*stdd
32private:
33        int isNextGauss;
34        double nextGauss;
35};
36
37extern RandomGener RndGen;
38
39#endif
Note: See TracBrowser for help on using the repository browser.