python 向量取整数_随机整数向量| 使用Python的线性代数

python 向量取整数

Prerequisite:

先决条件:

  • Defining a Vector using list

    使用列表定义向量

  • Defining Vector using Numpy

    使用Numpy定义向量

Random Integer Vector is a type of vector having a random integer value at each entry. Such types of vectors have a huge importance in Simulation and Machine Learning. Random Integer Vector can be defined by its Upper Limit, Lower Limit, and Length of the Vector (i.e. number of entries).

随机整数向量是在每个条目处具有随机整数值的向量类型。 这种类型的向量在仿真和机器学习中具有极其重要的意义。 随机整数向量可以通过其上限下限和向量的长度(即条目数)来定义。

In this article, we are going to create a random integer vector using inbuilt function numpy.random.randint().

在本文中,我们将使用内置函数numpy.random.randint()创建一个随机整数向量。

Syntax:

句法:

numpy.random.randint(low, up, length)
low - lower limit for choosing random integer value
up - upper limit for choosing random integer value
length - Length of the desired vector

Application:

应用:

  1. Machine Learning

    机器学习

  2. Probability

    可能性

  3. Constraint Based Programming

    基于约束的编程

  4. Monte Carlo Simulation

    蒙特卡罗模拟

随机整数向量的Python程序 (Python program for random integer vector)

# Linear Algebra Learning Sequence
# Random Integer Vector
import numpy as np
# Example 1, length 20
t1 = np.random.randint(0,30,20)
print('Example : ', t1)
# Example 2, length 20
t2 = np.random.randint(0,100,20)
print('\n\nExample : ', t2)
# Example 3, length 20
t3 = np.random.randint(0,300,20)
print('\n\nExample : ', t3)
# Example 4, length 30
t4 = np.random.randint(40,45,30)
print('\n\nExample : ', t4)

Output:

输出:

Example :  [ 6  2 14 27 23 12 15  7 23 18 17 16 13 12 19  7 27 21 28 23]
Example :  [65 41 80 12 12 91 10 77 31 66 29 98 11 40 41 52  7 18 80 26]
Example :  [126  14 190  21 259 268 168  88 252 270 243 112 237 2  
38 112 229 106 85  48]
Example :  [44 40 42 40 42 42 44 43 43 42 41 42 42 44 42 41 41 40 
40 42 43 40 42 40 44 44 40 43 40 40]

翻译自: https://www.includehelp.com/python/random-integer-vector.aspx

python 向量取整数

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/544170.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Spring 夺命 35 问!

有人说,“Java程序员都是Spring程序员”,可以看出Spring在Java世界里举足轻重的作用。基础1.Spring是什么?特性?有哪些模块?Spring Logo一句话概括:Spring 是一个轻量级、非入侵式的控制反转 (IoC) 和面向切…

Android百度地图开发03之地图控制 + 定位

前两篇关于百度地图的blog写的是,一些基本图层的展示 和 覆盖物的添加地理编码和反地理编码。 接下来,这篇blog主要说一些关于地图控制方面的内容和定位功能。 百度地图提供的关于地图的操作主要有:单击、双击、长按、缩放、旋转、俯视等。 地…

软件工程需要学什么_为什么我们需要软件工程?

软件工程需要学什么Software engineering is the application of the set of pre-defined procedures while developing any project. But why do we need Software engineering? What factors made us implement these predefined set of procedures and protocols while dev…

IDEA 版 Postman 面世了,功能真心强大!

IDEA是最常用的开发工具,很多程序员都想把它打造成一站式开发平台,于是安装了各种各样的插件。最近发现了一款IDEA插件RestfulFastRequest,细节做的真心不错,说它是IDEA版的Postman也不为过,推荐给大家!Res…

DNS子域授权

转载于:https://blog.51cto.com/changeflyhigh/1697257

mongo数据库插入数据_深入研究Mongo数据库

mongo数据库插入数据More popularly known as "mongoDB". It is a no-sql based database. 俗称“ mongoDB” 。 这是一个基于无SQL的数据库。 BASIC STRUCTURE OF MONGO DB MONGO DB的基本结构 A COLLECTION IN MONGODB having 3 DOCUMENTS MONGODB中有3个文档的集…

java方法重载和重载方法_我们可以在Java中重载main()方法吗?

java方法重载和重载方法The question is that "can we overload main() method in Java?" 问题是“我们可以在Java中重载main()方法吗?” Yes, We can overload the main() method in Java. 是的,我们可以重载Java中的main()方法 。 JVM cal…

五分钟,手撸一个Spring容器!

Spring是我们最常用的开源框架,经过多年发展,Spring已经发展成枝繁叶茂的大树,让我们难以窥其全貌。这节,我们回归Spring的本质,五分钟手撸一个Spring容器,揭开Spring神秘的面纱!从什么是IOC开始…

一步一步搭建客服系统 (7) 多人共享的电子白板、画板

多人共享、同时操作的电子白板,让不同的参入者以不同的颜色来画画;可以保存当前room的内容,以让后来者可以直接加载所有内容。 在github上找到一个用html5 canvas实现的一个电子白板的例子: https://github.com/kblcuk/canvas-whi…

Spring Cloud OpenFeign 的 5 个优化小技巧!

作者 | 磊哥来源 | Java中文社群(ID:javacn666)转载请联系授权(微信ID:GG_Stone)OpenFeign 是 Spring 官方推出的一种声明式服务调用和负载均衡组件。它的出现就是为了替代已经进入停更维护状态的 Feign&am…

java的equals方法_Java Vector equals()方法与示例

java的equals方法向量类的equals()方法 (Vector Class equals() method) equals() method is available in java.util package. equals()方法在java.util包中可用。 equals() method is used to check whether this Vector is the same or equals to the given object (ob) or …

推荐几个好文章

1 cocos2dx各种行动 http://www.cnblogs.com/linux-ios/archive/2013/04/06/3001946.html 2 cocos2dx自己定义曲线 http://blog.csdn.net/ufolr/article/details/7447773 3 lua中载入cocostudio动画,触发帧事件(非常全,非常具体。还有源代码…

treeset java_Java TreeSet first()方法与示例

treeset javaTreeSet类的first()方法 (TreeSet Class first() method) first() method is available in java.util package. first()方法在java.util包中可用。 first() method is used to retrieve the first lowest element in this TreeSet. first()方法用于检索此TreeSet中…

Java常用类:7000字一次性帮你总结好啦!

来源:cnblogs.com/lwtyyds/p/15678152.html常用类概述内部类内部类的分类:1.成员内部类(非静态内部类)2.局部内部类4.匿名内部类Object类Object类常用方法:1.equals方法2.hashCode方法3.toString方法4.finzlize方法包装…

CentOS6.4系统启动失败故障排查

转:http://www.centoscn.com/CentosBug/osbug/2014/1028/4011.html 操作系统启动失败如下图报错: 故障现象: 从图中可以看到,操作系统启动的过程中,fsck在执行文件系统检测时出现了错误,并且是在检查/dev/m…

hashmap clone_Java HashMap clone()方法与示例

hashmap cloneHashMap类clone()方法 (HashMap Class clone() method) clone() method is available in java.util package. clone()方法在java.util包中可用。 clone() method is used to get a cloned copy of this HashMap instance or in other words, we can say it return…

Linux内存管理--物理内存分配【转】

转自:http://blog.csdn.net/myarrow/article/details/8682819 1. First Fit分配器 First Fit分配器是最基本的内存分配器,它使用bitmap而不是空闲块列表来表示内存。在bitmap中,如果page对应位为1,则表示此page已经被分配&#xf…

JDK的一个Bug,监听文件变更要小心了

背景 在某些业务场景下,我们需要自己实现文件内容变更监听的功能,比如:监听某个文件是否发生变更,当变更时重新加载文件的内容。看似比较简单的一个功能,但如果在某些JDK版本下,可能会出现意想不到的Bug。本…

hashset java_Java HashSet clear()方法与示例

hashset javaHashSet类的clear()方法 (HashSet Class clear() method) clear() method is available in java.util package. clear()方法在java.util包中可用。 clear() method is used to clear all of the element exists from this HashSet. clear()方法用于清除此HashSet中…

推荐 17 个压箱底的常用类库

前言在java的庞大体系中,其实有很多不错的小工具,也就是我们平常说的:轮子。如果在我们的日常工作当中,能够将这些轮子用户,再配合一下idea的快捷键,可以极大得提升我们的开发效率。今天我决定把一些压箱底…