You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bayesflow/adapters/transforms/standardize.py
+16-11Lines changed: 16 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,8 @@ class Standardize(ElementwiseTransform):
16
16
17
17
z = (x - mean(x))/std(x)
18
18
19
-
Important to note that when specifying a mean and sd user should be careful to specify which variables should be standardized. Please see examples.
19
+
Important to note that when specifying a mean and sd user should be careful to specify which variables should
20
+
be standardized. Please see examples.
20
21
21
22
Parameters:
22
23
mean: integer or float used to specify a mean if known but will be estimated from data when not provided
@@ -25,31 +26,35 @@ class Standardize(ElementwiseTransform):
25
26
standardization happens individually for each dimension
26
27
momentum: float in (0,1) specifying the momentum during training
27
28
28
-
Examples:
29
+
Examples:
30
+
31
+
1) Standardize all variables using estimated mean and standard deviation
29
32
30
-
1) Standardize all variables using estimated mean and standard deviation
31
-
32
33
adapter = (
33
34
bf.adapters.Adapter()
34
35
.standardize()
35
36
)
36
-
37
37
38
-
2) Standardize all with same known mean and standard deviation. In this example all data is drawn from a standard normal
38
+
39
+
2) Standardize all with same known mean and standard deviation. In this example all data is drawn from a
40
+
standard normal
39
41
40
42
adapter = (
41
43
bf.adapters.Adapter()
42
44
.standardize(mean = 1, sd = 0)
43
45
)
44
-
45
46
46
-
3) Mix of specified and auto-computed means/sds. Suppose we have priors for "beta" and "sigma" where we know the mean and standard deviations. However for our simulated data "x" and "y" the mean and standard deviations are unknown. Then standardize should be used in several stages specifying which variables to include or exclude.
47
-
47
+
48
+
3) Mix of specified and auto-computed means/sds. Suppose we have priors for "beta" and "sigma" where we
49
+
know the mean and standard deviations. However for our simulated data "x" and "y" the mean and standard
50
+
deviations are unknown. Then standardize should be used in several stages specifying which variables to
51
+
include or exclude.
52
+
48
53
adapter = (
49
54
bf.adapters.Adapter()
50
55
.standardize(include = "beta", mean = 1) # specify only mean/sd
51
-
.standardize(include = "sigma", mean = 0.6, sd = 1) # specify both mean and sd
52
-
.standardize(exclude = ["beta", "sigma"]) # specify neither mean nor sd
56
+
.standardize(include = "sigma", mean = 0.6, sd = 1) # specify both mean and sd
57
+
.standardize(exclude = ["beta", "sigma"]) # specify neither mean nor sd
0 commit comments