--
-- auxilliary random number functions
--

function RN_donut_offset (MinR, MaxR)

   local Sign = 1.0
   if (RN () < 0.5) then Sign = -1.0
   end
   return RN () * (MaxR - MinR) + MinR * Sign
end

function RN_table_index (ArrSize)

   return math.min (math.floor (RN () * (ArrSize + 1)) + 1, ArrSize)
end

function RN_balance ()

   return (RN () - 0.5)
end

function RN_index (Min, Max)

   -- if they ujust specify one param, then treat it as though ti's RN_index (1, Min)
   if (not Max) then

      Max = Min
      Min = 1
   end

   -- compute the index
   return math.floor (RN () * (Max - Min) + Min)
end

function RN_range (Min, Max)

   if (not Max) then

      Max = Min
      Min = 0
   end

   return RN () * (Max - Min) + Min
end

function RN_get_seed ()

   return RN_index (50000)
end