tfp.stats.variance
Stay organized with collections
Save and categorize content based on your preferences.
Estimate variance using samples.
tfp.stats.variance(
x, sample_axis=0, keepdims=False, name=None
)
Given N
samples of scalar valued random variable X
, variance may
be estimated as
Var[X] := N^{-1} sum_{n=1}^N (X_n - Xbar) Conj{(X_n - Xbar)}
Xbar := N^{-1} sum_{n=1}^N X_n
x = tf.random.normal(shape=(100, 2, 3))
# var[i, j] is the sample variance of the (i, j) batch member of x.
var = tfp.stats.variance(x, sample_axis=0)
Notice we divide by N
(the numpy default), which does not create NaN
when N = 1
, but is slightly biased.
Args |
x
|
A numeric Tensor holding samples.
|
sample_axis
|
Scalar or vector Tensor designating axis holding samples, or
None (meaning all axis hold samples).
Default value: 0 (leftmost dimension).
|
keepdims
|
Boolean. Whether to keep the sample axis as singletons.
|
name
|
Python str name prefixed to Ops created by this function.
Default value: None (i.e., 'variance' ).
|
Returns |
var
|
A Tensor of same dtype as the x , and rank equal to
rank(x) - len(sample_axis)
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-21 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-11-21 UTC."],[],[]]