IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
RandomIterator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antonio Augusto Alves Junior
RandomIterator
Commits
15d31c12
Commit
15d31c12
authored
2 years ago
by
Antonio Augusto Alves Junior
Browse files
Options
Downloads
Patches
Plain Diff
solving the issue
#4
. Corresponding tests added.
parent
67eefe7e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/plot_stream.cpp
+47
-30
47 additions, 30 deletions
tests/plot_stream.cpp
with
47 additions
and
30 deletions
tests/plot_stream.cpp
+
47
−
30
View file @
15d31c12
...
@@ -46,12 +46,14 @@ using namespace matplot;
...
@@ -46,12 +46,14 @@ using namespace matplot;
template
<
typename
Generator
>
template
<
typename
Generator
>
void
plot_normal
(
char
*
name
,
uint64_t
seed
);
void
plot_normal
(
const
char
*
name
,
uint64_t
seed
);
template
<
typename
Generator
>
template
<
typename
Generator
>
void
plot_exponential
(
char
*
name
,
uint64_t
seed
);
void
plot_exponential
(
const
char
*
name
,
uint64_t
seed
);
template
<
typename
Generator
>
void
plot_uniform
(
const
char
*
name
,
uint64_t
seed
);
int
main
(
int
argv
,
char
**
argc
)
int
main
(
int
argv
,
char
**
argc
)
{
{
...
@@ -72,44 +74,26 @@ int main(int argv, char** argc)
...
@@ -72,44 +74,26 @@ int main(int argv, char** argc)
plot_exponential
<
random_iterator
::
squares4_128
>
(
"squares4_{128}"
,
default_seed
);
plot_exponential
<
random_iterator
::
squares4_128
>
(
"squares4_{128}"
,
default_seed
);
plot_exponential
<
random_iterator
::
ars
>
(
"ars"
,
default_seed
);
plot_exponential
<
random_iterator
::
ars
>
(
"ars"
,
default_seed
);
plot_exponential
<
random_iterator
::
threefry
>
(
"threefry"
,
default_seed
);
plot_exponential
<
random_iterator
::
threefry
>
(
"threefry"
,
default_seed
);
show
();
/*
std::uniform_real_distribution<double> udist(0.0, 1.0);
std::normal_distribution<double> ndist(0.0, 1.0);
std::exponential_distribution<double> edist(1.0);
auto urng_stream = random_iterator::make_stream( udist, RNG, 0);
auto nrng_stream = random_iterator::make_stream( ndist, RNG, 1);
auto erng_stream = random_iterator::make_stream( edist, RNG, 1);
std::vector<double> data_normal_distribution;
plot_uniform
<
random_iterator
::
philox
>
(
"philox"
,
default_seed
);
std::vector<double> data_uniform_distribution;
plot_uniform
<
random_iterator
::
squares3_64
>
(
"squares3_{64}"
,
default_seed
);
std::vector<double> data_exponential_distribution;
plot_uniform
<
random_iterator
::
squares4_64
>
(
"squares4_{64}"
,
default_seed
);
plot_uniform
<
random_iterator
::
squares3_128
>
(
"squares3_{128}"
,
default_seed
);
plot_uniform
<
random_iterator
::
squares4_128
>
(
"squares4_{128}"
,
default_seed
);
plot_uniform
<
random_iterator
::
ars
>
(
"ars"
,
default_seed
);
plot_uniform
<
random_iterator
::
threefry
>
(
"threefry"
,
default_seed
);
for(size_t i =0; i<NSAMPLES; ++i){
data_normal_distribution.push_back(nrng_stream[i]);
show
();
data_uniform_distribution.push_back(urng_stream[i]);
data_exponential_distribution.push_back(erng_stream[i]);
}
subplot(1, 3, 0);
auto data_normal_histogram = hist(data_normal_distribution, histogram::normalization::probability);
subplot(1, 3, 1);
auto data_uniform_histogram = hist(data_uniform_distribution, histogram::normalization::probability);
subplot(1, 3, 2);
auto data_exponential_histogram = hist(data_exponential_distribution, histogram::normalization::probability);
show();
*/
return
0
;
return
0
;
}
}
template
<
typename
Generator
>
template
<
typename
Generator
>
void
plot_normal
(
char
*
name
,
uint64_t
seed
){
void
plot_normal
(
const
char
*
name
,
uint64_t
seed
){
auto
f
=
figure
(
false
);
auto
f
=
figure
(
false
);
auto
tile
=
f
->
nexttile
();
auto
tile
=
f
->
nexttile
();
...
@@ -144,7 +128,7 @@ void plot_normal(char* name, uint64_t seed){
...
@@ -144,7 +128,7 @@ void plot_normal(char* name, uint64_t seed){
}
}
template
<
typename
Generator
>
template
<
typename
Generator
>
void
plot_exponential
(
char
*
name
,
uint64_t
seed
){
void
plot_exponential
(
const
char
*
name
,
uint64_t
seed
){
auto
f
=
figure
(
false
);
auto
f
=
figure
(
false
);
auto
tile
=
f
->
nexttile
();
auto
tile
=
f
->
nexttile
();
...
@@ -175,3 +159,36 @@ void plot_exponential(char* name, uint64_t seed){
...
@@ -175,3 +159,36 @@ void plot_exponential(char* name, uint64_t seed){
f
->
draw
();
f
->
draw
();
}
}
template
<
typename
Generator
>
void
plot_uniform
(
const
char
*
name
,
uint64_t
seed
){
auto
f
=
figure
(
false
);
auto
tile
=
f
->
nexttile
();
Generator
RNG
(
default_seed
);
std
::
uniform_real_distribution
<
double
>
udist
(
0.0
,
1.0
);
auto
urng_stream
=
random_iterator
::
make_stream
(
udist
,
RNG
,
1
);
std
::
vector
<
double
>
data_uniform_distribution
;
for
(
size_t
i
=
0
;
i
<
NSAMPLES
;
++
i
){
data_uniform_distribution
.
push_back
(
urng_stream
[
i
]);
}
auto
data_uniform_histogram
=
hist
(
data_uniform_distribution
,
histogram
::
normalization
::
pdf
);
title
(
name
);
hold
(
on
);
auto
funiform
=
[
&
](
double
y
)
{
return
fabs
(
y
)
<
1
&&
y
>
0
;
};
fplot
(
funiform
,
std
::
array
<
double
,
2
>
{
-
0.5
,
1.5
})
->
line_width
(
2.0
);
f
->
draw
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment