Skip to content

Commit e016178

Browse files
committed
improve standardize doc further
1 parent 47f72ab commit e016178

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

bayesflow/adapters/transforms/standardize.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@
1212
class Standardize(ElementwiseTransform):
1313
"""
1414
Transform that when applied standardizes data using typical z-score standardization i.e. for some unstandardized
15-
data x the standardized version z would be
15+
data x the standardized version z would be
1616
17-
z = (x - mean(x))/std(x)
18-
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.
17+
z = (x - mean(x)) / std(x)
2118
2219
Parameters:
2320
mean: integer or float used to specify a mean if known but will be estimated from data when not provided
@@ -28,33 +25,34 @@ class Standardize(ElementwiseTransform):
2825
2926
Examples:
3027
31-
1) Standardize all variables using estimated mean and standard deviation
28+
1) Standardize all variables using their individually estimated mean and stds.
3229
3330
adapter = (
3431
bf.adapters.Adapter()
3532
.standardize()
3633
)
3734
3835
39-
2) Standardize all with same known mean and standard deviation. In this example all data is drawn from a
40-
standard normal
36+
2) Standardize all with same known mean and std.
4137
4238
adapter = (
4339
bf.adapters.Adapter()
44-
.standardize(mean = 1, sd = 0)
40+
.standardize(mean = 5, sd = 10)
4541
)
4642
4743
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.
44+
3) Mix of fixed and estimated means/stds. Suppose we have priors for "beta" and "sigma" where we
45+
know the means and stds. However for all other variables, the means and stds are unknown.
46+
Then standardize should be used in several stages specifying which variables to include or exclude.
5247
5348
adapter = (
5449
bf.adapters.Adapter()
55-
.standardize(include = "beta", mean = 1) # specify only mean/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
50+
# mean fixed, std estimated
51+
.standardize(include = "beta", mean = 1)
52+
# both mean and SD fixed
53+
.standardize(include = "sigma", mean = 0.6, sd = 3)
54+
# both means and stds estimated for all other variables
55+
.standardize(exclude = ["beta", "sigma"])
5856
)
5957
6058
"""

0 commit comments

Comments
 (0)