Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
ab3fc143
Commit
ab3fc143
authored
Nov 13, 2019
by
Philipp Arras
Browse files
Simplifyications
parent
af6cbb60
Pipeline
#63607
failed with stages
in 5 minutes and 35 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty5/library/correlated_fields.py
View file @
ab3fc143
...
...
@@ -409,15 +409,11 @@ class CorrelatedFieldMaker:
assert
space
<
ldom
if
ldom
==
1
:
return
self
.
total_fluctuation_realized
(
samples
)
res1
=
0.
res2
=
0.
res1
,
res2
=
0.
,
0.
for
s
in
samples
:
res1
=
res1
+
s
**
2
res2
=
res2
+
s
.
mean
(
space
)
**
2
res1
=
res1
/
len
(
samples
)
res2
=
res2
/
len
(
samples
)
res
=
res1
.
mean
()
-
res2
.
mean
()
return
np
.
sqrt
(
res
)
res1
+=
s
**
2
res2
+=
s
.
mean
(
space
)
**
2
return
np
.
sqrt
((
res1
-
res2
).
mean
()
/
len
(
samples
))
def
moment_slice_to_average
(
self
,
fluctuations_slice_mean
,
nsamples
=
1000
):
fluctuations_slice_mean
=
float
(
fluctuations_slice_mean
)
...
...
@@ -428,8 +424,7 @@ class CorrelatedFieldMaker:
mu
,
sig
=
_lognormal_moments
(
m
,
std
)
flm
=
np
.
exp
(
mu
+
sig
*
np
.
random
.
normal
(
size
=
nsamples
))
scm
*=
flm
**
2
+
1.
scm
=
np
.
mean
(
np
.
sqrt
(
scm
))
return
fluctuations_slice_mean
/
scm
return
fluctuations_slice_mean
/
np
.
mean
(
np
.
sqrt
(
scm
))
@
staticmethod
def
offset_amplitude_realized
(
samples
):
...
...
@@ -443,8 +438,7 @@ class CorrelatedFieldMaker:
res
=
0.
for
s
in
samples
:
res
=
res
+
(
s
-
s
.
mean
())
**
2
res
=
res
/
len
(
samples
)
return
np
.
sqrt
(
res
.
mean
())
return
np
.
sqrt
((
res
/
len
(
samples
)).
mean
())
@
staticmethod
def
stats
(
op
,
samples
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment