简体   繁体   English

在 scipy.stats 中定义用于 trapz 分布的 pdf 背后的逻辑

[英]Logic behind defining the pdf for trapz distribution in scipy.stats

need help to understand the logic behind defining the pdf for trapz distribution in scipy.stats.需要帮助来理解在 scipy.stats 中定义用于 trapz 分布的 pdf 背后的逻辑。

From Github Scipy.Stats repository its coded as:-来自 Github Scipy.Stats 存储库,其编码为:-

def _pdf(self, x, c, d):
    u = 2 / (d-c+1)

    return _lazyselect([x < c,
                        (c <= x) & (x <= d),
                        x > d],
                       [lambda x, c, d, u: u * x / c,
                        lambda x, c, d, u: u,
                        lambda x, c, d, u: u * (1-x) / (1-d)],
                        (x, c, d, u))

It's basically a chain of if x < c: ... elif c < x < d: ... elif d < x: ... , only for array-valued arguments.它基本上是if x < c: ... elif c < x < d: ... elif d < x: ...的链,仅适用于数组值 ZDBC11CAA5BDA99F77E6FBDADBD8824E7 Eg, If you have an array x , different of its elements need different branches of this if-elif chain.例如,如果你有一个数组x ,它的不同元素需要这个if-elif链的不同分支。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM