Numpy学习与应用(一)

本文通过对以下题目进行分析与解答,从而了解Numpy的用法。

其中第一节为基本知识介绍,第二节为题目解答。

题目如下:

基础知识:

1.numpy中的axis

axis常常出现在numpy对矩阵的操作中,指定不同的axis可以从不同方向(如二维矩阵中,axis=0沿纵向,axis=1沿横向)进行操作。


以下是解题过程中所需用到的函数:

1. numpy.random.normal(分别以loc和scale为均值与标准差,随机生成size个数)

numpy.random.normal(loc=0.0scale=1.0size=None)

Draw random samples from a normal (Gaussian) distribution.

The probability density function of the normal distribution, first derived by De Moivre and 200 years later by both Gauss and Laplace independently [R500500], is often called the bell curve because of its characteristic shape (see the example below).

The normal distributions occurs often in nature. For example, it describes the commonly occurring distribution of samples influenced by a large number of tiny, random disturbances, each with its own unique distribution [R500500].

Parameters:

loc : float or array_like of floats

Mean (“centre”) of the distribution.

scale : float or array_like of floats

Standard deviation (spread or “width”) of the distribution.

size : int or tuple of ints, optional

Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if loc and scale are both scalars. Otherwise, np.broadcast(loc, scale).size samples are drawn.

Returns:

out : ndarray or scalar

Drawn samples from the parameterized normal distribution.

2. scipy.linalg.toeplitz(生成一个第一行向量为c,第一列向量为r的托普利兹矩阵)

scipy.linalg. toeplitz ( cr=None )

Construct a Toeplitz matrix.

The Toeplitz matrix has constant diagonals, with c as its first column and r as its first row. If r is not given, r ==conjugate(c) is assumed.

Parameters:

c : array_like

First column of the matrix. Whatever the actual shape of c, it will be converted to a 1-D array.

r : array_like

First row of the matrix. If None, r = conjugate(c) is assumed; in this case, if c[0] is real, the result is a Hermitian matrix. r[0] is ignored; the first row of the returned matrix is [c[0], r[1:]]. Whatever the actual shape of r, it will be converted to a 1-D array.

Returns:

A : (len(c), len(r)) ndarray

The Toeplitz matrix. Dtype is the same as (c[0] + r[0]).dtype.

3. numpy.dot(如果a,b为一维矩阵,则计算二者的内积;若a,b为二维数组,则进行二者的矩阵乘法运算)

numpy. dot ( about=None
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值