python 向量取整数_随机整数向量| 使用Python的线性代数
python 向量取整數(shù)
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).
隨機整數(shù)向量是在每個條目處具有隨機整數(shù)值的向量類型。 這種類型的向量在仿真和機器學(xué)習(xí)中具有極其重要的意義。 隨機整數(shù)向量可以通過其上限 , 下限和向量的長度(即條目數(shù))來定義。
In this article, we are going to create a random integer vector using inbuilt function numpy.random.randint().
在本文中,我們將使用內(nèi)置函數(shù)numpy.random.randint()創(chuàng)建一個隨機整數(shù)向量。
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 vectorApplication:
應(yīng)用:
Machine Learning
機器學(xué)習(xí)
Probability
可能性
Constraint Based Programming
基于約束的編程
Monte Carlo Simulation
蒙特卡羅模擬
隨機整數(shù)向量的Python程序 (Python program for random integer vector)
# Linear Algebra Learning Sequence # Random Integer Vectorimport 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 向量取整數(shù)
總結(jié)
以上是生活随笔為你收集整理的python 向量取整数_随机整数向量| 使用Python的线性代数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 4g 中bis代表什么_BIS的完整形式
- 下一篇: ruby array_Array.sel