tfp.substrates.numpy.math.log_gamma_difference
Stay organized with collections
Save and categorize content based on your preferences.
Returns lgamma(y) - lgamma(x + y), accurately.
tfp.substrates.numpy.math.log_gamma_difference(
x, y, name=None
)
This is more accurate than subtracting lgammas directly because lgamma grows
as x log(x) - x + o(x)
, and thus subtracting the value of lgamma for two
close, large arguments incurs catastrophic cancellation.
When y >= 8
, the method is to partition lgamma into the Stirling
approximation and the correction log_gamma_correction
, symbolically cancel
the former, and compute and subtract the latter.
Args |
x
|
Floating-point Tensor. x should be non-negative, and elementwise no
more than y .
|
y
|
Floating-point Tensor. y should be positive.
|
name
|
Optional Python str naming the operation.
|
Returns |
lgamma_diff
|
Floating-point Tensor, the difference lgamma(y) - lgamma(x+y),
computed elementwise.
|
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."],[],[]]