SHARE
TWEET

Untitled

a guest Dec 15th, 2016 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. genSignal <- function(NcivsInGal     = 1e6,
  2.                       EmitStartRange = c(-5e9, 5e9),
  3.                       DistRange      = c(300,  1e5),  
  4.                       DurRange       = c(1000, 1e5)){
  5.  
  6.     signals = data.frame(EmitStartYBP = runif(nCivs, EmitStartRange[1], EmitStartRange[2]),
  7.                          Distance     = runif(nCivs, DistRange[1],      DistRange[2]),
  8.                          Duration     = runif(nCivs, DurRange[1],       DurRange[2]))
  9.  
  10.     signals$EmitEndYBP     = with(signals, EmitStartYBP + Duration)
  11.     signals$DetectStartYBP = with(signals, EmitStartYBP + Distance)
  12.     signals$DetectEndYBP   = with(signals, EmitEndYBP   + Distance)
  13.  
  14.     signals$Detectable = with(signals, DetectStartYBP <= 0 & DetectEndYBP >= 0)
  15.     return(signals)
  16. }
  17.  
  18. nGalaxies     = 1000
  19. propSignalHit = replicate(nGalaxies, mean(genSignal()$Detectable))
  20.  
  21. hist(propSignalHit, col = "Blue", breaks = 10, freq = T,
  22.      xlab = "Proportion of Signals Detectable",
  23.      main = paste("Mean =", mean(propSignalHit)))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top