Random Generator
 
Betöltés...
Keresés...
Nincs egyezés
uniform.cpp
Ugrás a fájl dokumentációjához.
1#include "uniform.h"
2#include <cstdlib>
3#include <ctime>
4#include <cmath>
5using namespace std;
6
7namespace bme {
8
9 double unif() {
10 return (rand()+1) / (static_cast<double>(RAND_MAX+2));
11 }
12
13 double unif(double a, double b) {
14 return (b - a) * unif() + a;
15 }
16
17 int unif(int n) {
18 if (n < 0) n = -n;
19 if (n == 0) { return 0; }
20 return static_cast<int>(unif() * n) + 1;
21 }
22
23 void seed() {
24 srand(time(0));
25 }
26}
Definition uniform.cpp:7
void seed()
Véletlenszám-generátort inicializálása.
Definition uniform.cpp:23
double unif()
Egyenletes eloszlás a (0,1) intervallumon.
Definition uniform.cpp:9
Véletlenszám-generátor.