【问题标题】:how to calculate PDF in tensorflow如何在tensorflow中计算PDF
【发布时间】:2017-12-08 10:30:16
【问题描述】:

在Matlab中,我可以通过使用计算高斯分布的概率密度函数(PDF)

x = [0.8147,0.9058,0.1270,0.9134,0.6324,0.0975,0.2785,0.5469,0.9575,0.9649]
y = normpdf(x,1.0,2.5)

输出:

y = 0.1591    0.1595    0.1501    0.1595    0.1579    0.1495    0.1531    0.1570    0.1596    0.1596

使用tensorflow,我试过这个

x = tf.variable([0.8147,0.9058,0.1270,0.9134,0.6324,0.0975,0.2785,0.5469,0.9575,0.9649],tf.float32)
y = tf.contrib.distributions.NormalWithSoftplusSigma.pdf(x)

我收到一个错误TypeError: pdf missing 1 required positional argument

如何在这个分布中输入 mu 和 sigma 值?得到类似的输出。

【问题讨论】:

    标签: python statistics tensorflow probability-density


    【解决方案1】:

    这个函数pdf更新为prob

    dist = tf.contrib.distributions.Normal(1.0, 2.5) 
    y = dist.prob(x)
    

    【讨论】:

      【解决方案2】:

      首先创建一个Normal distributions对象,然后使用pdf方法

      dist = tf.contrib.distributions.Normal(1.0, 2.5)
      y = dist.pdf(x)
      

      更多详情请见this

      【讨论】:

      • 详情链接失效
      猜你喜欢
      • 2017-07-10
      • 1970-01-01
      • 1970-01-01
      • 2020-04-09
      • 1970-01-01
      • 2017-07-25
      • 2016-06-14
      • 2017-07-20
      • 1970-01-01
      相关资源
      最近更新 更多