我认为这是一个简单的问题。但由于我没有经验,所以我遇到了麻烦。你能帮我个忙吗?
这是我的时间序列:
c(-3.29484936154311, -5.25024337115738, -10.0094826133245, -7.59859069779222,
-0.634475163333426, -1.39961957395026, -0.988708619117207, 8.33911920268179,
6.69377652602653, 13.0053128248198, 13.0018629429779, 21.3252463808843,
25.136699898852, 17.7829814769728, 21.3677139968423, 13.8998874806656,
5.71239138313202, 0.788238244428585, -2.10103480176752, 1.37427724040298,
1.23646409968202, 3.6919397664077, 8.75488669246337, 9.84041663853997,
7.80460925738588, 5.6086157852452, 4.96802398846251, 6.76402015535695,
9.29789674152941, 7.00336348072626, 13.3835482637509, 12.9566212013354,
13.3679661584688, 7.40001586709425, 1.95561787938673, 5.40161213443595,
0.0152010336995634, 1.1571246397115, -1.01327047839875, 4.07410069704891,
8.9795057638528, 5.45915437970998, 8.14097618850694, 0.23877044622459,
4.10795620657726, 6.72169733438464, 5.4521436044684, 6.69488814118149,
6.92824003507987, 13.0994267168349, 15.2609420004878, 13.7455599521328,
14.6162559854387, 15.9064694629687, 14.5390459106406, 19.212343082103,
-0.160543412067962, -1.83220618784191, -7.16983989168457, -12.2934656746314,
-22.1703259618016, -25.4015526568395, -13.0657548778433, -14.9075469329561,
-14.6549327942844, -9.8589086276669, -0.0705766138406894, -3.87145121806904,
-4.50857663256484, -7.39750111111114, 1.12527097937519, -5.84683499764979,
-5.47028369560702, -2.87494132859858, 1.82500137801333, 9.85903252133325,
2.67302375976323, 3.28540700066389, -1.50265787593533, -3.82212128201978,
-10.5006925914674, -16.6785801482274, -12.8139663199719, -8.42521976086733,
-4.96610959320779, -5.46514639194231, -1.09873459506639, -3.60109910491466,
-11.3595952566074, -15.6465184184212, -10.5979464349057, -8.25087329703925,
-14.9369277630748, -8.7371384819775, -0.696100997303495, 9.88702424422501,
3.39133447543236, 5.26755625904132, 10.9426939424616)
我如何计算非条件概率:Prob(y<0)
??
非常感谢。
答案 0 :(得分:1)
由于我想删除我的评论,我会在这里给出答案。
事件概率A
的频率估计是A
在一系列实验中出现的次数。现在您的活动是y > 0
。让我们使用逻辑值TRUE / FALSE来表示已发生但未发生。 y < 0
将返回这样的逻辑顺序。然后sum(y < 0)
将给出出现次数(因为TRUE为1,FALSE为0)。如果我们将其除以length(y)
,或等同于mean(y < 0)
,则我们估算Pr(y < 0)
。
您当然可以举办复合活动:0 < y < quantile(y, 0.4)
。在R中,我们通过mean(0 < y & y < quantile(y, 0.4))
估计其概率。
本质上,结果严格地介于0和1之间。