示例#1
0
文件: pi.py 项目: chris-ch/pystream
def gregory(dtype=float):
    """
    Return partial sums of the Gregory series converging to atan(1) == pi/4.

    Yield 1 - 1/3 + 1/5 - 1/7 + ... computed with the given type.

    :param dtype:
    :return:
    """
    return sequence(dtype(1), step=2) >> StreamMap(lambda x: 1 / x) >> alt_sign >> StreamFold(operator.add)
示例#2
0
def main():
    # should be X(t) = mu * t + sigma * W(t)
    print(cstream.sequence() >> wiener(1.) >> cstream.StreamTake(100) >> list)