python 矩阵随机生成
2016-02-16 10:14
696 查看
Generate a sparse matrix
Generate a sparse matrix of the given shape and density
with uniformly distributed values.
scipy.sparse.rand(m, n, density=0.01, format='coo', dtype=None, random_state=None)
Parameters:
m, n : int
shape of the matrix
density : real, optional
density of the generated matrix: density equal to one means a full matrix, density
of 0 means a matrix with no non-zero items.
format : str, optional
sparse matrix format.
dtype : dtype, optional
type of the returned matrix values.
random_state : {numpy.random.RandomState, int}, optional
Random number generator or random seed. If not given, the singleton numpy.random
will be used.
example:
>>>
sp.rand(4,3,density=1,).todense()
matrix([[ 0.54318062, 0.73848674, 0.66199091],
[ 0.55778929, 0.74904161, 0.97990645],
[ 0.92667378, 0.07833997, 0.18023915],
[ 0.02989316, 0.88534361, 0.00998536]])
Generate a sparse matrix of the given shape and density
with uniformly distributed values.
scipy.sparse.rand(m, n, density=0.01, format='coo', dtype=None, random_state=None)
Parameters:
m, n : int
shape of the matrix
density : real, optional
density of the generated matrix: density equal to one means a full matrix, density
of 0 means a matrix with no non-zero items.
format : str, optional
sparse matrix format.
dtype : dtype, optional
type of the returned matrix values.
random_state : {numpy.random.RandomState, int}, optional
Random number generator or random seed. If not given, the singleton numpy.random
will be used.
example:
>>>
sp.rand(4,3,density=1,).todense()
matrix([[ 0.54318062, 0.73848674, 0.66199091],
[ 0.55778929, 0.74904161, 0.97990645],
[ 0.92667378, 0.07833997, 0.18023915],
[ 0.02989316, 0.88534361, 0.00998536]])
相关文章推荐
- 优美的 Python
- 十条建议帮你提高Python编程效率
- Python 布尔操作(and/or,Boolean operator)与位操作(&/|,Bitwise operator)
- bpython 功能强大的Python shell
- python Sparse matrices 单位矩阵
- python小点心--Event
- 深入解读Python解析XML的几种方式
- python(3)-内置函数2
- Atitit.sql ast 表达式 语法树 语法 解析原理与实现 java php c#.net js python
- Atitit.sql ast 表达式 语法树 语法 解析原理与实现 java php c#.net js python
- Atitit.sql ast 表达式 语法树 语法 解析原理与实现 java php c#.net js python
- 我的Mac之路(1)—— 安装虚拟机,以及打造VIM IDE for Python
- python语法学习
- 深入解读Python解析XML的几种方式
- bpython 功能强大的Python shell
- 十条建议帮你提高Python编程效率
- 轻松实现python搭建微信公众平台
- python实现红包裂变算法
- Python实现快速排序和插入排序算法及自定义排序的示例
- Python的GUI框架PySide的安装配置教程