- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我使用 scipy.stats 中的各种连续分布(例如 norm)。所以如果我想找到 P(Z < 0.5) 我会这样做:
from scipy.stats import norm
norm(0, 1).cdf(0.5) # Z~N(0,1)
是否有一种工具(scipy.stats 或 statsmodels 或其他)可用于描述离散分布,然后计算 CDF/CMF 等?我可以自己编写代码,但我想知道是否存在某些东西,例如:
pdf(x) = 1/3 for x = 1,2,3; else 0
然后我可以构建 2 个向量 x=[1,2,3], p = [1/3, 1/3, 1/3] 并将它们输入到一个库类中,该库类将提供 .cdf() 等?
最佳答案
我猜你正在寻找 scipy.stats.rv_discrete
在这里。来自docs :
rv_discrete
is a base class to construct specific distribution classes and instances for discrete random variables. It can also be used to construct an arbitrary distribution defined by a list of support points and corresponding probabilities.
来自文档的示例:
from scipy import stats
xk = np.arange(7)
pk = (0.1, 0.2, 0.3, 0.1, 0.1, 0.0, 0.2)
custm = stats.rv_discrete(name='custm', values=(xk, pk))
你的例子:
In [1]: import numpy as np
In [2]: from scipy import stats
In [3]: custm = stats.rv_discrete(name='custm', values=((1, 2, 3), (1./3, 1./3, 1./3)))
In [4]: custm.cdf(2.5)
Out[4]: 0.66666666666666663
关于Python scipy - 指定自定义离散分布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41664533/
如何在 Flutter 中使 slider 离散看起来像上图? slider discrete 最佳答案 使用 divisions Slider 的属性(property)小部件将其分成相等的部分,然
我正在创建一个带有颜色条的散点图 plt.scatter(X, Y, c=Z) plt.colorbar() plt.show() plt.close() 其中 X 和 Y 是 float 组,Z 是
我刚刚在 android studio 中发现了 seekbar 离散小部件,我发现它非常有用,但我不知道如何删除步骤指示器,或者用更合适的可绘制对象更改它们。 有人设法做到了吗? 这是我当前搜索栏的
问题 请注意以下问题:巫师可以创建和销毁 rune 。创建一个新的 rune 需要消耗与先前创建的 rune 数量成比例的法力。摧毁 rune 会恢复创建 rune 所用的法力。下面,我提出一个可能的
我正在尝试使用 ggplot2 中的 sf 和 geom_sf 制作 map ,其中一组点数据使用连续颜色比例(-1 到 1),一组线数据使用离散比例(a、b、c、d)着色。但是,当我在同一张 map
我正在尝试在具有连续状态(dim.= 20)和离散操作(3 个可能的操作)的环境中找到最佳策略。并且有一个特定的时刻:对于最佳策略,一个操作(称为“操作 0”)的选择频率应比其他两个操作高得多(频率约
仅使用 x-y 位置移动绘制圆弧的最佳方法是什么?例如,假设我想在点 (4,4) 处绘制一个半径为 4 的圆。让我们看看我的“抽屉”从 (4,0) 开始,每个方向的分辨率为 0.1 步。我将如何创建一
我正在使用一个使用广义加法模型的随机站点级效应来拟合一个模型,该模型在 mgcv 中实现。 R 包。我一直在使用函数 gam() 执行此操作但是,为了加快速度,我需要转到 bam()框架,与gam()
这个问题在这里已经有了答案: Make a line separated by group in bar chart (3 个答案) 关闭上个月。 我正在尝试使用 ggplot2 在条形图的每个条上
这个问题在这里已经有了答案: Make a line separated by group in bar chart (3 个答案) 关闭上个月。 我正在尝试使用 ggplot2 在条形图的每个条上
是否可以同时使用 Intel HD 4000 集成显卡和独立 GPU,OpenCL(或 CUDA)作为设备,CPU 作为主机?我想要一些代码在集成显卡上运行,而其他代码同时在我的 GPU 上运行。 最
我是一名优秀的程序员,十分优秀!