Guest User

Untitled

a guest
Jun 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. abort "usage: generate_weibull_data <mean> <iterations>" if ARGV.length != 2
  4.  
  5. scale = ARGV[0].to_f / 2
  6.  
  7. r_code = <<EOF
  8. for (i in 1:#{ARGV[1]}) {
  9. Wscale = #{ARGV[0]}/.43
  10. d = c(rweibull(100000, .5, Wscale), rweibull(100000, 1, Wscale), rweibull(100000, 10, Wscale))
  11. write.table(d[d < 19],
  12. col.names = F,
  13. row.names = F,
  14. file = paste("W_m#{ARGV[0]}_i", i, ".txt", sep = ""))
  15. }
  16. EOF
  17.  
  18. temp_filename = %x[mktemp].chomp
  19. temp_file = File.new(temp_filename, "w")
  20. temp_file.puts(r_code)
  21. temp_file.close
  22.  
  23. %x[R --vanilla --quiet CMD BATCH #{temp_filename} /dev/null]
  24.  
  25. File.delete(temp_filename)
Add Comment
Please, Sign In to add comment