Created
September 26, 2011 13:57
-
-
Save jrsconfitto/1242288 to your computer and use it in GitHub Desktop.
This will generate random data that is timestamped in a CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! ruby | |
# This will generate a negative number set that i can use for testing my compression analysis | |
# | |
# Example: | |
# NegNumSet numberOfPoints [max] [freq] | |
# | |
# Arguments (all are optional so far): | |
# 1: numberOfPoints - the number of points to generate | |
# 2: Max - the maximum distance from zero that the data point values can have | |
# 3: Freq - the maximum distance in seconds between each point | |
if ARGV[0] | |
numberOfPoints = ARGV[0].to_i | |
else | |
numberOfPoints = 10 | |
end | |
if ARGV[1] | |
max = ARGV[1].to_f | |
else | |
max = 10.0 | |
end | |
if ARGV[2] | |
freq = ARGV[2].to_f | |
else | |
freq = 0.5 | |
end | |
puts "Generated data" | |
random = Random.new | |
timestamp = Time.now | |
(0..numberOfPoints).each do | |
timestamp = timestamp + random.rand( freq ) | |
data = random.rand( max ) | |
# Generate the sign for the number randomly | |
sign = random.rand() | |
if sign < 0.5 | |
data = -data | |
end | |
# Output our random generated data set | |
puts "#{timestamp.strftime("%m/%d/%Y %H:%M:%S.%3N")},#{data.to_s}\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment