python中如何将生成等差数列和等比数列

在python库numpy 中提供了函数linspace和logspace函数用于生产等差数列和等比数列。

    1.linspace函数生成等差数列

def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None):

指定初始值、终止值、数量、是否包含终止值,默认为包含。



2.logspace函数生成等比数列
def logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None):
指定初始值、终止值、数量、是否包含终止值,默认为包含。

 
原文地址:https://www.cnblogs.com/fuhang/p/8046150.html