我有一个特别的Pareto distribution。比如说,
Pareto(beta=0.00317985, alpha=0.147365, gamma=1.0283)
我从this answer中得到,现在我想在matplotlib中绘制一个概率密度函数(PDF)的图。所以我相信x轴都是正实数,y轴是一样的
我如何准确地获取适当的PDF信息并进行打印以编程方式获取数学PDF函数或坐标是此问题的一项要求。
更新:
drawPDF
方法返回一个包含PDF坐标的图形对象。但是,我不知道如何以编程方式访问这些坐标。我当然不想将对象转换为字符串,也不想使用正则表达式提取信息:
In [45]: pdfg = distribution.drawPDF()
In [46]: pdfg
Out[46]: class=Graph name=pdf as a function of X0 implementation=class=GraphImplementation name=pdf as a function of X0 title= xTitle=X0 yTitle=PDF axes=ON grid=ON legendposition=topright legendFontSize=1
drawables=[class=Drawable name=Unnamed implementation=class=Curve name=Unnamed derived from class=DrawableImplementation name=Unnamed legend=X0 PDF data=class=Sample name=Unnamed implementation=class=Sam
pleImplementation name=Unnamed size=129 dimension=2 data=[[-1610.7,0],[-1575.83,0],[-1540.96,0],[-1506.09,0],[-1471.22,0],[-1436.35,0],[-1401.48,0],[-1366.61,0],...,[-1331.7,6.95394e-06],[2852.57,6.85646e-06]] color
=red fillStyle=solid lineStyle=solid pointStyle=none lineWidth=2]
我假设您希望执行不同的任务:
每个需求都需要不同的脚本。请让我详细介绍一下
我首先创建
Pareto
发行版:要绘制PDF,请使用
drawPDF()
方法。这将创建一个ot.Graph
,可以直接在Jupyter笔记本或IPython中查看。我们可以使用View
强制创建绘图:该图显示:
要在单个点计算PDF,请使用
computePDF(x)
,其中x
是ot.Point()
。这也可以是Pythonlist
或tuple
或1D numpyarray
,因为转换由OpenTURNS自动管理:前面的脚本打印:
为了计算一系列值的PDF,我们可以使用
computePDF(x)
,其中x是ot.Sample()
。这也可以是列表的Pythonlist
或2D numpyarray
,因为转换是由OpenTURNS自动管理的前面的脚本打印:
相关问题 更多 >
编程相关推荐