Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository 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
SWIFT
SWIFTsim
Commits
e54523a1
Commit
e54523a1
authored
6 years ago
by
Folkert Nobels
Browse files
Options
Downloads
Patches
Plain Diff
Clean the testRandom.c file
parent
aa97c92e
No related branches found
No related tags found
1 merge request
!742
Fix the random number generator
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/testRandom.c
+0
-17
0 additions, 17 deletions
tests/testRandom.c
with
0 additions
and
17 deletions
tests/testRandom.c
+
0
−
17
View file @
e54523a1
...
@@ -41,8 +41,6 @@ int main(int argc, char* argv[]) {
...
@@ -41,8 +41,6 @@ int main(int argc, char* argv[]) {
message
(
"Seed = %d"
,
seed
);
message
(
"Seed = %d"
,
seed
);
srand
(
seed
);
srand
(
seed
);
/* Time-step size */
/* Time-step size */
const
int
time_bin
=
29
;
const
int
time_bin
=
29
;
...
@@ -54,11 +52,6 @@ int main(int argc, char* argv[]) {
...
@@ -54,11 +52,6 @@ int main(int argc, char* argv[]) {
const
long
long
idoffset
=
id
+
2
;
const
long
long
idoffset
=
id
+
2
;
message
(
"Testing id=%lld time_bin=%d"
,
id
,
time_bin
);
message
(
"Testing id=%lld time_bin=%d"
,
id
,
time_bin
);
//char buffer[32];
//snprintf(buffer, sizeof(char)*32, "fileII%i.txt", i);
//FILE *fp;
//fp = fopen(buffer,"w");
double
total
=
0
.,
total2
=
0
.;
double
total
=
0
.,
total2
=
0
.;
int
count
=
0
;
int
count
=
0
;
...
@@ -71,8 +64,6 @@ int main(int argc, char* argv[]) {
...
@@ -71,8 +64,6 @@ int main(int argc, char* argv[]) {
double
pearsonIDs
=
0
.;
double
pearsonIDs
=
0
.;
double
totalID
=
0
.;
double
totalID
=
0
.;
double
total2ID
=
0
.;
double
total2ID
=
0
.;
//message("Max nr timesteps = %lld",max_nr_timesteps);
/* Check that the numbers are uniform over the full-range of useful
/* Check that the numbers are uniform over the full-range of useful
* time-steps */
* time-steps */
...
@@ -90,8 +81,6 @@ int main(int argc, char* argv[]) {
...
@@ -90,8 +81,6 @@ int main(int argc, char* argv[]) {
total
+=
r
;
total
+=
r
;
total2
+=
r
*
r
;
total2
+=
r
*
r
;
count
++
;
count
++
;
//const unsigned int test = 127LL*(ti_current - 1LL) + 124429LL;
//fprintf(fp, "%f %lld %lld\n", r, (test) % 1514917LL, ti_current );
/* For the pearson correlation of time i and i-1 */
/* For the pearson correlation of time i and i-1 */
sum_previous_current
+=
r
*
previous
;
sum_previous_current
+=
r
*
previous
;
...
@@ -101,17 +90,14 @@ int main(int argc, char* argv[]) {
...
@@ -101,17 +90,14 @@ int main(int argc, char* argv[]) {
pearsonIDs
+=
r
*
r_2ndid
;
pearsonIDs
+=
r
*
r_2ndid
;
totalID
+=
r_2ndid
;
totalID
+=
r_2ndid
;
total2ID
+=
r_2ndid
*
r_2ndid
;
total2ID
+=
r_2ndid
*
r_2ndid
;
}
}
//fclose(fp);
const
double
mean
=
total
/
(
double
)
count
;
const
double
mean
=
total
/
(
double
)
count
;
const
double
var
=
total2
/
(
double
)
count
-
mean
*
mean
;
const
double
var
=
total2
/
(
double
)
count
-
mean
*
mean
;
/* Pearson correlation calculation for different times */
/* Pearson correlation calculation for different times */
const
double
mean_xy
=
sum_previous_current
/
(
(
double
)
count
-
1
.
f
);
const
double
mean_xy
=
sum_previous_current
/
(
(
double
)
count
-
1
.
f
);
const
double
correlation
=
(
mean_xy
-
mean
*
mean
)
/
var
;
const
double
correlation
=
(
mean_xy
-
mean
*
mean
)
/
var
;
message
(
"Correlation = %f"
,
correlation
);
/* Pearson correlation for different IDs */
/* Pearson correlation for different IDs */
const
double
meanID
=
totalID
/
(
double
)
count
;
const
double
meanID
=
totalID
/
(
double
)
count
;
...
@@ -120,9 +106,6 @@ int main(int argc, char* argv[]) {
...
@@ -120,9 +106,6 @@ int main(int argc, char* argv[]) {
const
double
meanID_xy
=
pearsonIDs
/
(
double
)
count
;
const
double
meanID_xy
=
pearsonIDs
/
(
double
)
count
;
const
double
correlationID
=
(
meanID_xy
-
mean
*
meanID
)
/
pow
(
var
*
varID
,
.
5
f
);
const
double
correlationID
=
(
meanID_xy
-
mean
*
meanID
)
/
pow
(
var
*
varID
,
.
5
f
);
message
(
"Correlation ID = %f"
,
correlationID
);
/* Verify that the mean and variance match the expected values for a uniform
/* Verify that the mean and variance match the expected values for a uniform
* distribution */
* distribution */
if
((
fabs
(
mean
-
0
.
5
)
/
0
.
5
>
2e-4
)
||
if
((
fabs
(
mean
-
0
.
5
)
/
0
.
5
>
2e-4
)
||
...
...
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