Skip to content

Commit f5049be

Browse files
committed
added examples to standardize transformation documentation
1 parent 9e58aad commit f5049be

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

bayesflow/adapters/transforms/standardize.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,42 @@ class Standardize(ElementwiseTransform):
1616
1717
z = (x - mean(x))/std(x)
1818
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.
20+
1921
Parameters:
2022
mean: integer or float used to specify a mean if known but will be estimated from data when not provided
2123
std: integer or float used to specify a standard devation if known but will be estimated from data when not provided
2224
axis: integer representing a specific axis along which standardization should take place. By default
2325
standardization happens individually for each dimension
2426
momentum: float in (0,1) specifying the momentum during training
2527
28+
Examples:
29+
30+
1) Standardize all variables using estimated mean and standard deviation
31+
32+
adapter = (
33+
bf.adapters.Adapter()
34+
.standardize()
35+
)
36+
37+
38+
2) Standardize all with same known mean and standard deviation. In this example all data is drawn from a standard normal
39+
40+
adapter = (
41+
bf.adapters.Adapter()
42+
.standardize(mean = 1, sd = 0)
43+
)
44+
45+
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+
48+
adapter = (
49+
bf.adapters.Adapter()
50+
.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
53+
)
54+
2655
"""
2756

2857
def __init__(

0 commit comments

Comments
 (0)