PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

36 rindas
1.4KB

  1. # Analyze dice data to establish if it is random
  2. setwd("~/Development/hardware-rng/avr-hardware-random-number-generation/Entropy/examples/Dice")
  3. library(foreign)
  4. library(prettyR)
  5. sink("analysis.prn")
  6. Dice.data <- read.csv("dice.txt")
  7. Dice.data$Sum <- Dice.data$Die1 + Dice.data$Die2
  8. png(filename="cumulative.png", width=800, height=600)
  9. hist(Dice.data$Sum,
  10. freq=FALSE,
  11. breaks=c(1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5,12.5),
  12. main="Distribution of Dice rolls",
  13. xlab="Combined value",
  14. ylab="Probability",
  15. ylim=c(0.00,0.20))
  16. dev.off()
  17. Dice.data.freq <- freq(Dice.data, display.na=FALSE,decr.order=FALSE)
  18. Dice.data.freq <-as.data.frame(Dice.data.freq["Sum"])
  19. print(Dice.data.freq)
  20. events <- sum(Dice.data.freq$Sum)
  21. print(chisq.test(Dice.data.freq$Sum, p=c(0.0278,0.0556,0.0833,0.1111,0.1389,0.1666,0.1389,0.1111,0.0833,0.0556,0.0278)))
  22. Independent.Rolls <- c(Dice.data$Die1,Dice.data$Die2)
  23. png(filename="independent.png",width=800,height=600)
  24. hist(Independent.Rolls,
  25. freq=FALSE,
  26. breaks=c(0.5,1.5,2.5,3.5,4.5,5.5,6.5),
  27. main="Distribution of Dice rolls",
  28. xlab="Independent values",
  29. ylab="Probability",
  30. ylim=c(0.00,0.20))
  31. dev.off()
  32. Independent.Rolls.freq <- freq(Independent.Rolls, display.na=FALSE,decr.order=FALSE)
  33. Independent.Rolls.freq <- as.data.frame(Independent.Rolls.freq["Independent.Rolls"])
  34. print(Independent.Rolls.freq)
  35. print(chisq.test(Independent.Rolls.freq))
  36. sink()