<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_weighted_random_index(self,weights):
 """Return an index of an array based on the weights if a random number between 0 and 1 is less than an index return the lowest index :type weights: list :return: index :rtype: int """

    tot = float(sum([float(x) for x in weights]))
    fracarray = [weights[0]]
    for w in weights[1:]:
      prev = fracarray[-1]
      fracarray.append(w+prev)
    #print fracarray
    rnum = self._random.random()*tot
    #print rnum
    #sys.exit()
    for i in range(len(weights)):
      if rnum < fracarray[i]: return i
    sys.stderr.write("Warning unexpected no random\n")