Advertisement
rejcsibejcsi

Hehehehe

Mar 9th, 2022
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.78 KB | None | 0 0
  1.  
  2.  
  3. set.seed (101); x=0.2*qgamma (runif (100), 1.2)
  4.  
  5. hist (x, col="green")
  6.  
  7. a=c(0,0.5,1.5,3.5,6,20) p=vector ()
  8.  
  9. for (i in 1: (length (a)-1)) p[i]=pexp (a [i+1])-pexp (a [i])
  10. p
  11.  
  12. np-length (x) *p
  13.  
  14. np
  15.  
  16. x. cut-cut (x/mean (x), breaks =a)
  17.  
  18. x. cut
  19.  
  20. nu-vector ()
  21.  
  22. for (i in 1: (length (a)-1)) nu[i] =table(x.cut) [[i]]
  23.  
  24. nu
  25.  
  26. chi2.x=sum ((nu-np) ^2/np)
  27.  
  28. chi2.x
  29.  
  30. cat ("p=", 1-pchisq (chi2.x, length (a)-3), "\n")
  31.  
  32. k=5
  33.  
  34. p=seq (from-0, to=1,1/k)
  35.  
  36. P
  37.  
  38. a=gexp (p)
  39.  
  40. a
  41.  
  42. np-vector ()
  43.  
  44. for (i in 1: (length(a)-1)) np [i]=1/k
  45.  
  46. np-np*length (x).
  47.  
  48. пр
  49.  
  50. x. cut-cut (x/mean (x), breaks-a)
  51.  
  52. x. cut
  53.  
  54. nu-vector ()
  55.  
  56. for (i in 1: (length (a)-1)) nu [i]=table (x.cut) [[i]]
  57.  
  58. nu
  59.  
  60. chi2.x-sum ((nu-np) ^2/np)
  61.  
  62. chi2.x cat ("p=", 1-pchisq (chi2.x, length (a)-3), "\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement