-
Notifications
You must be signed in to change notification settings - Fork 0
/
randumb.rb
93 lines (72 loc) · 1.53 KB
/
randumb.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#make a hash where kv [iter_size,order]:
# example: [[10,100] => [...]
#iter_attr = (start, end, order_mag)
#problems
# with method chaining
class StatCheck
attr_accessor
:range
:result
:repeat_calculation
:iter_length
def initialize
@result = result
@iter_length = iter_length
@range = range
@order_magnitude = order_magnitude
@repeat_calculation = repeat_calculation
@proportion = proportion
end
def define_values
result = [[],[]]
iter_length = 10
range = (1..10)
order_mag = 12
repeat_calculation = 10
end
def gen
iter_length.times {
result[0]
.push(
(range).yield_self {rand(15)}
)
}
end
def is_member_bool
result[0].each do |i|
result[1].push((range).member?(i))
end
puts result[1]
end
def organize_bool_result
bool_result = Hash[ "t",[],"f",[] ]
result[1].each do |i|
if i == true
bool_result["t"] << i
else
bool_result["f"] << i
end
end
def display_result
proportion = []
proportion.push(bool_result["t"].count, bool_result["f"].count)
def pct
total = (
proportion[0] + proportion[1]
)
puts " pct true is #{proportion[0] / total * 100}"
end
puts "count is "
puts proportion
puts "pct is "
puts pct
puts "rand values"
puts result[0]
end
end
end
te = StatCheck.new
te.gen
te.is_member_bool
te.organize_bool_result
te.display_result