Module: RThelper

Defined in:
lib/ms/rt/rt_helper.rb

Class Method Summary collapse

Class Method Details

.gaussian(x, mu, sd, h) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/ms/rt/rt_helper.rb', line 13

def gaussian(x,mu,sd,h)
  x = x.to_f
  mu = mu.to_f
  sd = sd.to_f
  h = h.to_f
  return h*Math.exp(-(x-mu)**2/(sd**2))
end

.normalized_gaussian(x, mu, sd) ⇒ Object



5
6
7
8
9
10
# File 'lib/ms/rt/rt_helper.rb', line 5

def normalized_gaussian(x,mu,sd)
  x = x.to_f
  mu = mu.to_f
  sd = sd.to_f
  return ((1/(Math.sqrt(2*(Math::PI)*(sd**2))))*(Math.exp(-(((x-mu)**2)/((2*sd)**2)))))
end

.RandomFloat(a, b) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/ms/rt/rt_helper.rb', line 22

def RandomFloat(a,b)
  a = a.to_f
  b = b.to_f
  random = rand(2147483647.0) / 2147483647.0
  diff = b - a
  r = random * diff
  return a + r
end