<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def weighted_median(d, w):
 """A utility function to find a median of d based on w Parameters d : array (n, 1), variable for which median will be found w : array (n, 1), variable on which d's median will be decided Notes ----- d and w are arranged in the same order Returns ------- float median of d Examples -------- Creating an array including five integers. We will get the median of these integers. Creating another array including weight values for the above integers. The median of d will be decided with a consideration to these weight values. Applying weighted_median function 4 """

    dtype = [('w', '%s' % w.dtype), ('v', '%s' % d.dtype)]
    d_w = np.array(list(zip(w, d)), dtype=dtype)
    d_w.sort(order='v')
    reordered_w = d_w['w'].cumsum()
    cumsum_threshold = reordered_w[-1] * 1.0 / 2
    median_inx = (reordered_w >= cumsum_threshold).nonzero()[0][0]
    if reordered_w[median_inx] == cumsum_threshold and len(d) - 1 > median_inx:
        return np.sort(d)[median_inx:median_inx + 2].mean()
    return np.sort(d)[median_inx]