Advertisement
Guest User

do prva pod D

a guest
Feb 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #Exercise 1
  2. #a)
  3. x=rbinom(100,5,1/2)
  4. x
  5. #b)
  6. min(x); max(x); mean(x); sd(x); quantile(x); IQR(x); range(x);
  7. library(Hmisc)
  8. describe(x)
  9. summary(x)
  10. our.mode = function(x)
  11. {
  12. ux = unique(x)
  13. tab = tabulate(match(x,ux))
  14. ux[tab==max(tab)]
  15. }
  16. m = our.mode(x)
  17. m
  18. #v)
  19. hist(x,freq=F,col="red", main="Histogram na X",xlab="Pronajdeni razliki")
  20. lines(density(x),col="blue", lwd=4)
  21. curve(dbinom(x,5,1/2), add=T, col="green",lwd=4)
  22. #g)
  23. f1 = summary(as.factor(x))[["3"]]/100; f1
  24. f2 = dbinom(3,5,1/2); f2
  25. "Razlikata megju f1 i f2 e:"; abs(f1-f2);
  26. #d)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement