def dyno_hist(x, window=None, probability=True, edge_weight=<NUM_LIT:1.>):
x = np.sort(x)<EOL>if probability:<EOL><INDENT>x = x - x[<NUM_LIT:0>]<EOL>x = x / float(x[-<NUM_LIT:1>] or <NUM_LIT:1>)<EOL><DEDENT>window = window or <NUM_LIT:1><EOL>window = min(max(window, <NUM_LIT:1>), int(len(x) / <NUM_LIT>))<EOL>window += <NUM_LIT:1><EOL>delta = x[(window - <NUM_LIT:1>):] - x[:(<NUM_LIT:1> - window)]<EOL>densities = float(window - <NUM_LIT:1>) / (len(delta) + window - <NUM_LIT:2>) / delta<EOL>h = pd.Series(densities, index=x[window // <NUM_LIT:2>:][:len(delta)])<EOL>if probability:<EOL><INDENT>if h.index[<NUM_LIT:0>] > <NUM_LIT:0>:<EOL><INDENT>h = pd.Series(edge_weight * densities[<NUM_LIT:0>], index=[<NUM_LIT:0>]).append(h)<EOL><DEDENT>if h.index[-<NUM_LIT:1>] < <NUM_LIT:1>:<EOL><INDENT>h = h.append(pd.Series(edge_weight * densities[-<NUM_LIT:1>], index=[<NUM_LIT:1.>]))<EOL><DEDENT><DEDENT>return h<EOL>
Probability Distribution function from values
    Arguments:
      probability (bool): whether the values should be min/max scaled to lie on the range [0, 1]
    Like `hist` but smoother, more accurate/useful
    Double-Normalization:
      The x values are min/max normalized to lie in the range 0-1 inclusive
      The pdf is normalized to integrate/sum to 1.0
    >>> h = dyno_hist(np.arange(100), window=5)
    >>> abs(sum(np.diff(h.index.values) * h.values[1:]) - 1.) < 0.00001
    True
    >>> h = dyno_hist(np.arange(50), window=12)
    >>> abs(sum(np.diff(h.index.values) * h.values[1:]) - 1.) < 0.00001
    True
    >>> h = dyno_hist(np.random.randn(1000), window=42)
    >>> abs(sum(np.diff(h.index.values) * h.values[1:]) - 1.0) < 0.04
    True