为了绘制三个变量x1,x2和x3的经验累积密度,我在r中使用了以下内容:
plot.ecdf(x1, col="blue",
main="Distribution XYZ",
xlab="x_i", ylab="Prob(x_i<=y)")
lines(ecdf(x2), col="red") # adds a line
lines(ecdf(x3), col="green") # adds line
legend(600,0.6, # places a legend from (x,y)=(600,0.6) on
c("x1","x2","x3"), # puts text in the legend
lty=c(1,1,1), # gives the legend appropriate symbols (lines)
lwd=c(1,1,1),col=c("blue","red","green")) # gives the legend lines the correct color and width
Run Code Online (Sandbox Code Playgroud)
然而,得到的图除了框之外在0和1处具有两条水平线(虚线).并且,盒子的原点在垂直轴上具有零空间,在水平轴上具有零左侧的空间.您可以建议如何删除这些空间和其他行.我想,但不能发布情节.
编辑:可以生成示例数据,如下所示:
n <- 1000; u <- runif(n)
a <- -4.46; b <- 1.6; c <- -4.63
d <- ( a * u ) + (b * …
Run Code Online (Sandbox Code Playgroud) 我想转换
['17-10-2010 07:15:30', '13-05-2011 08:20:35', "15-01-2013 09:09:09"]
Run Code Online (Sandbox Code Playgroud)
进入Numpy
日期时间对象.
import numpy as np
[np.datetime64(x) for x in ['17-10-2010 07:15:30', '13-05-2011 08:20:35', "15-01-2013 09:09:09"]]
Run Code Online (Sandbox Code Playgroud)
提出来ValueError: Could not convert object to NumPy datetime
.但是,以下按照我的意图工作
[np.datetime64(x) for x in ['2010-10-17 07:15:30', '2011-05-13 08:20:35', "2012-01-15 09:09:09"]]
Run Code Online (Sandbox Code Playgroud)
我怎样才能将我的数组,与符合格式Numpy
的datetime64
功能要求?
我使用Numpy版本1.7.0.在python 3.4中
如何从、和x
的连续三角形分布中进行绘制并获取特定值的 CDF 。我不明白如何设置参数。我想要得到相当于在 中做的事情。 mode=0
lower limit=-1
upper limit=1
numpyp.random.triangular(left=-1, mode=0, right=1)
Scipy
我尝试了以下操作,但我不确定这是否是我所追求的。
scipy.stats.triang.cdf([-1,-0.5,0,0.5,1], c=0.5, loc=-1, scale=2)
并获得:array([ 0, 0.125, 0.5, 0.875, 1.])
这似乎是正确的。
我不明白为什么
scipy.stats.triang.expect(func=lambda x: x, c = 0.5, loc=0.5, scale=1)
正在产生错误消息
_argcheck() missing 1 required positional argument: 'c'
尽管c
提供了论据。