Put outside X_seq in LocaScoreMC

This commit is contained in:
Paul-Corbalan 2022-04-12 10:50:29 +02:00
parent eb61523c3c
commit d3a893bc95
1 changed files with 9 additions and 23 deletions

View File

@ -283,36 +283,17 @@ ScoreDistrib <- function(lambda0, lambda1, NbSeq, T){
### Local score calculation ### Local score calculation
```{r} ```{r}
LocaScoreMC <- function(lambda0, lambda1, NbSeq, tbe0, T){ LocaScoreMC <- function(lambda0, lambda1, NbSeq, T, X_seq, P_X, tbe0){
E = ComputeE(lambda0, lambda1) E = ComputeE(lambda0, lambda1)
pvalue = c() pvalue = c()
X = c() X = c()
score_max=floor(E*log(lambda1/lambda0)) min_X = min(X_seq)
max_X = max(X_seq)
## Calcul score_min
score_min_c=floor(E*log(lambda1/lambda0)+E*(lambda0-lambda1)*T)
l=seq(score_min_c,score_max,1)
borne_inf=(l-E*log(lambda1/lambda0))/(E*(lambda0-lambda1))
borne_sup=(l+1-E*log(lambda1/lambda0))/(E*(lambda0-lambda1))
proba.l=pexp(rate=lambda0,borne_inf)-pexp(rate=lambda0,borne_sup)
S=sum(proba.l)
new.proba.s=proba.l/S
xp = l
P_X = proba.l/S
min_X = min(xp)
max_X = max(xp)
for (i in 1:NbSeq){ for (i in 1:NbSeq){
x = floor(E*log(dexp(tbe0[[i]], rate = lambda1)/dexp(tbe0[[i]], rate = lambda0))) x = floor(E*log(dexp(tbe0[[i]], rate = lambda1)/dexp(tbe0[[i]], rate = lambda0)))
#print(range(x))
print(length(tbe0[[i]]))
if (min(x)==Inf){
print(tbe0[[i]])
}
X = c(X,x) X = c(X,x)
LS = localScoreC(x)$localScore[1] LS = localScoreC(x)$localScore[1]
@ -330,6 +311,7 @@ score_min_c=floor(E*log(lambda1/lambda0)+E*(lambda0-lambda1)*T)
### Experience plan ### Experience plan
```{r} ```{r}
NbSeq = 10**3 NbSeq = 10**3
T = 10
for (lambda0 in (1:5)){ for (lambda0 in (1:5)){
for (lambda1 in c(2,4,6)){ for (lambda1 in c(2,4,6)){
if (lambda0 < lambda1){ if (lambda0 < lambda1){
@ -343,7 +325,11 @@ for (lambda0 in (1:5)){
tbe0[[i]]=tbei tbe0[[i]]=tbei
} }
LS_H0 = LocaScoreMC(lambda0, lambda1, NbSeq, tbe0, T) Score = ScoreDistrib(lambda0, lambda1, NbSeq, T)
X_seq = Score$X
P_X = Score$P_X
LS_H0 = LocaScoreMC(lambda0, lambda1, NbSeq, T, X_seq, P_X, tbe0)
print(summary(LS_H0)) print(summary(LS_H0))
cat("---\n") cat("---\n")