当前位置:网站首页>[noi simulation race] I don't know which CF paper title it is (probability expectation, martingale's stop time theorem)
[noi simulation race] I don't know which CF paper title it is (probability expectation, martingale's stop time theorem)
2022-07-23 13:18:00 【DD(XYX)】
Topic


Answer key
The paper :( Cannot read ) Bloomberg 《 Martingales and a class of probability and expectation problems about stopping time 》
Time theorem of martingale
Martingale is a special kind of stochastic process , Originated from the mathematical description of fair gambling games . Suppose we were watching a gambling game from the beginning , Now we have got the former t t t Second observation , So when the first t + 1 t+1 t+1 second Expectations of observations Equal to the t t t Of a second Observed value when , We just call this a fair gambling game .
random process : In a random background , moment i i i There will be state X i X_i Xi , Record them in turn to obtain the random process .
martingale : For a random process { X 0 , X 1 , . . . } \{X_0,X_1,...\} { X0,X1,...} , If E ( X n + 1 ∣ X 0 , X 1 , . . . , X n ) = X n E(X_{n+1}|X_0,X_1,...,X_n)=X_n E(Xn+1∣X0,X1,...,Xn)=Xn , We call this stochastic process martingale .
notes : E ( X n + 1 ∣ X 0 , X 1 , . . . , X n ) E(X_{n+1}|X_0,X_1,...,X_n) E(Xn+1∣X0,X1,...,Xn) It's conditional expectation , And guaranteed Expected state The definition of is existing and reasonable .
Stop time theorem : For any dwell t t t ( End the observation at this time , stay I don't know the random process in the middle Discuss the expectation of pause state ), Yes E ( X t ) = X 0 E(X_t)=X_0 E(Xt)=X0 .
Conclusion of potential energy function
Consider a random process { A 0 , A 1 , . . . } \{A_0,A_1,...\} { A0,A1,...}, When it is determined that the termination status is A t A_t At When , How to find the stop time t t t The expectations of the E ( t ) E(t) E(t) , We can construct a function Φ ( A ) \Phi(A) Φ(A) , Satisfy :
- E ( Φ ( A n + 1 ) − Φ ( A n ) ∣ A 0 , A 1 , . . . , A n ) = − 1 E(\Phi(A_{n+1})-\Phi(A_n)|A_0,A_1,...,A_n)=-1 E(Φ(An+1)−Φ(An)∣A0,A1,...,An)=−1 , Potential energy is expected to decrease with time .
- Φ ( A t ) \Phi(A_t) Φ(At) Constant value , And Φ ( A i ) = Φ ( A t ) \Phi(A_i)=\Phi(A_t) Φ(Ai)=Φ(At) If and only if i = t i=t i=t , The final state only corresponds to a potential energy .
By construction B i = Φ ( A i ) + i B_i=\Phi(A_i)+i Bi=Φ(Ai)+i , You know E ( B n + 1 ∣ B 0 , B 1 , . . . , B n ) = B n E(B_{n+1}|B_0,B_1,...,B_n)=B_n E(Bn+1∣B0,B1,...,Bn)=Bn , therefore { B i } \{B_i\} { Bi} It is also a martingale , According to the stop time theorem , Yes E ( B t ) = B 0 ⇒ E ( Φ ( A t ) + t ) = Φ ( A 0 ) ⇒ Φ ( A t ) + E ( t ) = Φ ( A 0 ) E(B_t)=B_0~\Rightarrow~E(\Phi(A_t)+t)=\Phi(A_0)~\Rightarrow~\Phi(A_t)+E(t)=\Phi(A_0) E(Bt)=B0 ⇒ E(Φ(At)+t)=Φ(A0) ⇒ Φ(At)+E(t)=Φ(A0)
So get the calculation method of pause expectation E ( t ) = Φ ( A 0 ) − Φ ( A t ) E(t)=\Phi(A_0)-\Phi(A_t) E(t)=Φ(A0)−Φ(At) .
Back to this scrap problem
( Put together a six word title
We define state by n n n Dimension vector , Then we can legally define the expectation of the state , And I was surprised to find that the random process is martingale !
Now we have to define a potential energy function Φ ( A ⃗ ) \Phi(\vec{A}) Φ(A) , Meet each expectation and reduce 1 .
Might as well try. Φ ( A ⃗ ) = ∑ f ( a i ) \Phi(\vec{A})=\sum f(a_i) Φ(A)=∑f(ai) , Make m = ∑ a i m=\sum a_i m=∑ai( m m m It is the same. ), Examine each a i a_i ai and f ( a i ) f(a_i) f(ai) The change of , Available by definition
∑ i = 1 n a i ( m − a i ) m ( m − 1 ) ( f ( a i + 1 ) − f ( a i ) + f ( a i − 1 ) − f ( a i ) ) = − 1 \sum_{i=1}^{n} \frac{a_i(m-a_i)}{m(m-1)}\left( f(a_i+1)-f(a_i)+f(a_i-1)-f(a_i) \right)=-1 i=1∑nm(m−1)ai(m−ai)(f(ai+1)−f(ai)+f(ai−1)−f(ai))=−1
Try to construct ? If you can become ∑ i = 1 n a i ( 1 − m ) m ( m − 1 ) \sum_{i=1}^{n}\frac{a_i(1-m)}{m(m-1)} ∑i=1nm(m−1)ai(1−m) How nice , Make
( f ( a i + 1 ) − f ( a i ) ) − ( f ( a i ) − f ( a i − 1 ) ) = 1 − m m − a i \big(f(a_i+1)-f(a_i)\big)-\big(f(a_i)-f(a_i-1)\big)=\frac{1-m}{m-a_i} (f(ai+1)−f(ai))−(f(ai)−f(ai−1))=m−ai1−m
Look at the left side of the formula and you will find it very beautiful , Make h ( x ) h(x) h(x) by f ( x ) f(x) f(x) The function after the difference twice ( ∑ i = 1 n h ( i ) = f ( n + 1 ) − f ( n ) \sum_{i=1}^{n}h(i)=f(n+1)-f(n) ∑i=1nh(i)=f(n+1)−f(n)), that
h ( x ) = 1 − m m − x h(x)=\frac{1-m}{m-x} h(x)=m−x1−m
We can directly prefix and find all f ( a i ) f(a_i) f(ai) , Time complexity O ( a log P ) O(a\log P) O(alogP) , But we still need to find f ( m ) f(m) f(m) , The most efficient method of direct recursion is time and space O ( m ) O(m) O(m) Of , But we notice that this subscript is exactly equal to m m m , Can have wonderful properties :
f ( m ) = ∑ i = 0 m − 1 ∑ j = 0 i 1 − m m − j = ∑ j = 0 m − 1 1 − m m − j ⋅ ( m − j ) = m ( 1 − m ) f(m)=\sum_{i=0}^{m-1}\sum_{j=0}^{i}\frac{1-m}{m-j}=\sum_{j=0}^{m-1}\frac{1-m}{m-j}\cdot (m-j) =m(1-m) f(m)=i=0∑m−1j=0∑im−j1−m=j=0∑m−1m−j1−m⋅(m−j)=m(1−m)
shock ! It takes only one multiplication to get the answer !
Total time complexity O ( a log P ) O(a\log P) O(alogP) .
CODE
#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<random>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#pragma GCC optimize(2)
using namespace std;
#define MAXN 100005
#define LL long long
#define ULL unsigned long long
#define ENDL putchar('\n')
#define DB double
#define lowbit(x) (-(x) & (x))
#define FI first
#define SE second
#define PR pair<int,int>
#define UIN unsigned int
int xchar() {
static const int maxn = 1000000;
static char b[maxn];
static int pos = 0,len = 0;
if(pos == len) pos = 0,len = fread(b,1,maxn,stdin);
if(pos == len) return -1;
return b[pos ++];
}
// #define getchar() xchar()
inline LL read() {
LL f = 1,x = 0;int s = getchar();
while(s < '0' || s > '9') {
if(s<0)return -1;if(s=='-')f=-f;s = getchar();}
while(s >= '0' && s <= '9') {
x = (x<<1) + (x<<3) + (s^48);s = getchar();}
return f*x;
}
void putpos(LL x) {
if(!x)return ;putpos(x/10);putchar((x%10)^48);}
inline void putnum(LL x) {
if(!x) {
putchar('0');return ;}
if(x<0) putchar('-'),x = -x;
return putpos(x);
}
inline void AIput(LL x,int c) {
putnum(x);putchar(c);}
const int MOD = 1000000007;
int n,m,s,o,k;
inline int qkpow(int a,int b) {
int res = 1;
while(b > 0) {
if(b & 1) res = res *1ll* a % MOD;
a = a *1ll* a % MOD; b >>= 1;
} return res;
}
int a[MAXN];
int f[MAXN];
int main() {
freopen("ball.in","r",stdin);
freopen("ball.out","w",stdout);
n = read(); m = 0;
for(int i = 1;i <= n;i ++) a[i] = read(),m += a[i];
for(int i = 1;i <= MAXN-5;i ++) {
f[i] = (MOD+1-m) *1ll* qkpow(m-i+1,MOD-2) % MOD;
}
for(int i = 1;i <= MAXN-5;i ++) (f[i] += f[i-1]) %= MOD;
for(int i = 1;i <= MAXN-5;i ++) (f[i] += f[i-1]) %= MOD;
int ans = m*1ll*(m-1) % MOD;
for(int i = 1;i <= n;i ++) {
(ans += f[a[i]]) %= MOD;
}
AIput(ans,'\n');
return 0;
}
边栏推荐
- 成功 万象奥科与CODESYS技术联合调测
- OpenVPN deployment
- 问题解决:Script file ‘Scripts\pip-script.py‘ is not present.
- PKU doctor's little sister: sharing dry goods at the bottom of the box | five tips to improve learning efficiency
- MySQL - composite query external connection
- 使用fastjson解析以及赋予json数据时,json字段顺序不一致问题
- 图像处理 图像特征提取与描述
- 力扣 729. 我的日程安排表 I
- Ronge answer script production (latest in 2020)
- Static routing principle and configuration
猜你喜欢
随机推荐
Beifu PLC and C transmit int type variables through ads communication
聊聊研发团队中的“人”
Shooting lesson 1-01: Introduction
【JZOF】08 二叉树的下一个结点
Beifu PLC and C transmit bool type variables through ads communication
射击 第 1-01 课:入门
Opencv image processing (Part 2): edge detection + template matching + Hough transform
Opencv image processing (Part 1): geometric transformation + morphological operation
Jenkins持续集成报错stderr: fatal: unsafe repository (‘/home/water/water‘ is owned by someone else)
互联网时代下,如何精细化用户运营?
太空射击 Part 2-2: 敌人精灵
太空射击 Part 2-3: 子弹与敌人碰撞处理
倍福PLC和C#通过ADS通信传输String数组类型变量
Confused, work without motivation? Career development hopeless? It's enough to read this article
Outlook tutorial, how to switch calendar views and create meetings in outlook?
Space shooting Part 2-3: dealing with the collision between bullets and the enemy
numpy:矩阵的元素选取
UI automation
雷达导论PART VII.3 SAR图像的形成和处理
EasyGBS平台出现录像无法播放并存在RTMP重复推流现象,是什么原因?








