-
Notifications
You must be signed in to change notification settings - Fork 1
/
randomgenerator.h
41 lines (30 loc) · 1 KB
/
randomgenerator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2015 Klimov Viktor, https://github.com/Vitek1425/
#ifndef RANDOMGENERATOR_H
#define RANDOMGENERATOR_H
#include <QJSEngine>
#include <random>
//Генератор случайных чисел
class RandomGenerator
{
public:
RandomGenerator();
RandomGenerator(qreal leftBorder, qreal rightBorder, const QString &distributionFunction);
qreal getRandom();
qreal getLeftBorder() const;
void setLeftBorder(const qreal &leftBorder);
qreal getRightBorder() const;
void setRightBorder(const qreal &rightBorder);
QString getDistributionFunction() const;
void setDistributionFunction(const QString &distributionFunction);
private:
//поиск обратного значения функции
qreal computeInverseValue(qreal y);
void updateFunction();
static std::default_random_engine m_generator;
qreal m_leftBorder;
qreal m_rightBorder;
QString m_distributionFunction;
QJSValue m_fun;
QJSEngine m_engine;
};
#endif // RANDOMGENERATOR_H