Pouvez-vous en fait me corriger le code suivant :
l'erreur retournée est la suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 x=c(1,2,3,4,5,6) fx=c(1486,694,195,37,10,1) moy <- sum(x*fx)/sum(fx) theta=moy i=0 repeat { n=sum(fx) deriveesec=function(theta) { -sum(fx)/theta**2+(n*exp(-theta))/(1-exp(-theta))**2 } i=i+1 thetaold=theta derivee=-n+sum(fx)/theta-(n*exp(-theta))/(1-exp(-theta)) theta=theta-derivee/deriveesec if (sqrt(sum((theta-thetaold)**2))<0.000001) {break} print(i) }
Error in derivee/deriveesec : non-numeric argument to binary operator
Partager