[ad_1]
Random Quantity generator in python play an vital a part of machine studying as they’re used for hyperparameter optimization, adjusting weights in deep studying amongst different crucial processes.
On this tutorial, you’ll discover ways to work with random quantity generator in python. After finishing tutorial, you’ll perceive:
- Random Numbers will be generated through pseudorandom quantity turbines.
- Tips on how to use random quantity generator in Python through the use of Random Library
- Tips on how to generate random numbers, arrays utilizing Numpy Library in Python
Put up Overview
This put up is split into three elements;
- Generate Random Numbers in Python utilizing Numpy.
- Generate Random Numbers utilizing Random Bundle.
- Pseudorandom Quantity Turbines
Additionally see: 150+ numpy workout routines
Random Quantity Generator in Python utilizing Numpy
Random quantity technology by beta distribution
Syntax = np.random.beta(a,b,dimension=None)
Parameters: a = Alpha, b = Beta, dimension = output form
#Code
np.random.beta(0.1,0.2,10)
#output
array([9.94314587e-01, 5.68371107e-09, 1.79747999e-15, 9.99999975e-01,
9.54623306e-01, 1.98234546e-11, 9.99241742e-01, 7.63562485e-01,
6.35681507e-19, 6.06761883e-01])
Do notice , your outcomes could also be completely different than mine.
Random quantity technology by binomial distribution
Syntax = np.random.binomial(n,p, dimension=None)
Parameters: n = trails, p = chance of success, dimension=output form
#Code
np.random.binomial(12,0.45,dimension=(10,10))
#output
array([[ 2, 5, 4, 6, 3, 8, 5, 6, 6, 6],
[ 4, 4, 6, 2, 6, 5, 7, 7, 5, 5],
[ 4, 5, 9, 5, 6, 8, 5, 6, 5, 9],
[ 6, 6, 3, 10, 6, 4, 4, 5, 4, 2],
[ 4, 4, 4, 8, 5, 6, 6, 9, 8, 4],
[ 5, 6, 7, 5, 4, 8, 6, 6, 8, 8],
[ 5, 4, 5, 4, 4, 8, 6, 4, 6, 5],
[ 8, 6, 7, 3, 6, 8, 6, 6, 3, 8],
[ 5, 6, 5, 2, 0, 4, 8, 6, 3, 6],
[ 6, 6, 5, 4, 5, 4, 6, 4, 1, 4]])
Random quantity technology by chi-square distribution
Syntax = np.random.chisquare(df,dimension=None)
df = diploma of freedom, dimension = output form
#Code
np.random.chisquare(4,15)
#output
array([2.05688127, 6.54292888, 7.58444005, 1.41428405, 3.45510839])
Random pattern technology from one dimensional array
Syntax: np.random.alternative(a, dimension=None, exchange=True, p=None)
a = 1-D array-like or integer, dimension = output form, exchange = whether or not the pattern is with or with out substitute, p = 1-D array-like, mainly possibilities related to every entry in an array.
#code
np.random.alternative(99,10)
#Output
array([40, 25, 19, 11, 70, 59, 96, 60, 46, 31])
Random quantity utilizing Dirichlet distribution
Syntax = np.random.Dirichlet(alpha,dimension=None)
alpha = sequence of floats, size okay. Parameter of the distribution, dimension = int or tuple of ints
#code
np.random.dirichlet((10,5,3),20)
#output
array([[0.34873703, 0.50649201, 0.14477096],
[0.72302467, 0.14258505, 0.13439028],
[0.44593801, 0.30128097, 0.25278102],
[0.57669678, 0.248177 , 0.17512622],
[0.65722768, 0.20791437, 0.13485795],
[0.43125162, 0.37553697, 0.19321141],
[0.67220118, 0.21503276, 0.11276607],
[0.61123727, 0.34694966, 0.04181308],
[0.4672246 , 0.39182022, 0.14095518],
[0.65058532, 0.11795275, 0.23146192],
[0.46989623, 0.16861265, 0.36149112],
[0.49329803, 0.22965147, 0.2770505 ],
[0.5461502 , 0.42545401, 0.0283958 ],
[0.48258243, 0.3543089 , 0.16310866],
[0.78807636, 0.19216025, 0.0197634 ],
[0.62870249, 0.15082051, 0.220477 ],
[0.70125648, 0.20164131, 0.09710221],
[0.40743831, 0.47110081, 0.12146088],
[0.66258158, 0.15799089, 0.17942753],
[0.604992 , 0.17898203, 0.21602597]])
Random quantity utilizing exponential distribution
Exponential distribution is analogue for geometric distribution.
Syntax = np.random.exponential(scale=1.0, dimension=None)
scale = scale parameter in exponential distribution, dimension = output
#code
np.random.exponential(1.0,12)
#output
array([1.53901421, 0.00407843, 0.69034784, 0.00645229, 1.30770943,
0.91196285, 0.05627425, 2.18012337, 0.36227942, 0.95762165,
0.2021032 , 0.55372096])
Random quantity utilizing F Distribution
Syntax = np.random.f(dfnum,dfden, dimension=None)
dfnum = levels of freedom in numerator, dfden = levels of freedom in denominator, dimension = output
#code
np.random.f(1,32,20)
#output
array([2.18329291e-01, 1.84782440e-01, 2.12774696e+00, 1.12441410e+00,
1.02170150e+01, 3.37106611e+00, 1.96755659e+00, 1.48220477e+00,
8.35775191e-02, 2.46688530e+00, 3.46894287e-03, 2.59068289e+00,
5.72647606e+00, 1.64655192e+00, 3.06830474e-01, 4.69981283e+00,
6.30859840e-01, 5.81015303e-02, 8.32573191e-01, 1.77738874e+00])
Random quantity utilizing Gamma Distribution
Syntax = np.random.gamma(form,scale,dimension=None)
form = form of gamma distribution, scale = scale of gamma distribution, dimension = output
#code
np.random.gamma(2,2,50)
#output
array([ 5.61038971, 1.87980268, 9.21168406, 0.50211389, 4.49239046,
5.6462828 , 2.28510082, 8.19927171, 2.10974037, 1.45227633,
3.51156658, 10.46277709, 6.48737276, 3.27999168, 2.65340486,
3.84875306, 4.58072407, 9.04503479, 1.75144226, 1.29185233,
4.23500524, 4.32123491, 4.92737636, 11.07087922, 1.04983773,
2.44339292, 4.19218176, 1.23159451, 0.24998529, 4.91658168,
0.39130511, 0.67353383, 4.18557953, 2.77099429, 2.149184 ,
2.6077436 , 2.52338003, 3.16772454, 2.604044 , 4.71774262,
0.73402083, 12.27478498, 11.29216053, 1.00798758, 4.92412465,
1.72588742, 0.29275699, 7.00638201, 3.26722238, 3.73876405])
Random quantity utilizing Geometric Distribution
Syntax = np.random.geometric(p, dimension=None)
p = chance of success of a person trial, dimension = output form
#code
np.random.geometric(0.4,30)
#Output
array([3, 5, 1, 4, 8, 2, 2, 1, 2, 2, 1, 6, 2, 2, 2, 1, 4, 2, 2, 1, 3, 5,
1, 2, 1, 2, 3, 3, 2, 3])
Additionally see: 200+ actual world pandas workout routines
Random quantity utilizing Gumbel Distribution
Syntax = np.random.gumbel(loc,scale,dimension)
loc = location of mode of the distribution, mainly imply of the distribution.
scale = normal deviation of the distribution
dimension = output form
#code
np.random.gumbel(0,0.1,100)
#output
array([-0.01264886, -0.05457963, 0.0843898 , 0.34074068, -0.05307558,
0.06433582, -0.1695451 , -0.14645811, 0.03898178, -0.01987542,
-0.02199712, 0.0749251 , 0.00687004, 0.09004047, 0.07847825,
0.02574964, 0.10624917, 0.12839777, 0.4262985 , 0.21630223,
0.01533838, 0.03597615, 0.0430698 , -0.00131731, 0.18342396,
-0.08420078, 0.17409966, -0.10005398, -0.07458114, 0.41475724,
-0.11825275, -0.00439019, 0.12797528, 0.03809518, 0.159117 ,
0.011672 , 0.10622612, 0.20746262, 0.25685402, 0.250753 ,
0.14206501, 0.05581919, 0.12087748, -0.03383174, -0.05765386,
-0.1449144 , 0.04086692, 0.00497343, 0.02631417, 0.26269266,
0.10156757, 0.00856622, 0.02453613, -0.12249999, 0.25628409,
-0.06335413, 0.2013471 , -0.06902403, -0.10629768, 0.15199275,
0.02905192, -0.17865511, 0.13934902, -0.06385898, -0.01145044,
-0.00251036, -0.00137692, 0.15426812, -0.05366544, 0.05318059,
0.04929693, 0.07410114, 0.0062325 , -0.0295167 , 0.05508052,
-0.11973995, 0.03925551, -0.04006653, 0.06931817, -0.06792028,
-0.08478426, 0.19539809, -0.09626313, 0.10161051, 0.02861612,
-0.05672591, -0.14016175, -0.00245946, -0.02707631, 0.03400508,
0.0614723 , -0.09563116, -0.09278934, 0.28280103, 0.14329151,
-0.06892652, 0.00647555, 0.009062 , 0.18278711, 0.09949122])
Random quantity utilizing Hyper geometric Distribution
Syntax = np.random.hypergeometric(ngood,nbad,nsample,dimension)
ngood = variety of methods to make a wide variety
nbad = variety of methods to make a foul choice
nsample = variety of gadgets sampled, must be much less or equal to ngood + nbad
dimension = output
np.random.hypergeometric(3,23,20,(5,5))
#output
array([[3, 2, 2, 2, 1],
[3, 3, 2, 2, 1],
[3, 2, 2, 3, 2],
[3, 2, 2, 3, 3],
[3, 2, 2, 3, 3]])
Random quantity utilizing Laplace Distribution or Double exponential distribution
Syntax = np.random.laplace(loc,scale,dimension)
loc is imply, scale is decay in laplace distribution and dimension is output worth.
np.random.laplace(1.5,0.1,(5,5))
#Output
array([[1.42807587, 1.5050976 , 1.32796969, 1.62732846, 1.31400319],
[1.48745584, 1.35276272, 1.46199887, 1.46549853, 1.50698112],
[1.42328241, 1.52520198, 1.5255751 , 1.32440192, 1.67327936],
[1.32773624, 1.27923195, 1.48312881, 1.54445111, 1.48701751],
[1.55136745, 1.35780056, 1.65747601, 1.51136827, 1.51172481]])
Random quantity utilizing Logistic Distribution
Syntax = np.random.logistic(loc,scale,dimension)
loc is imply or median, scale is parameter of distribution, dimension is output dimension
np.random.logistic(1.5, 0.5, (5,5))
#output
array([[ 1.51274115, 1.65056189, 2.60330958, 1.60680488, 0.3395394 ],[2.59911917, 1.83946185, 0.09725901, 1.87756181, 1.13284328],
[ 1.27374343, 0.05684854, -0.02349736, 0.73730424, 2.34477406],
[ 2.13677914, 4.85197751, 1.78438609, 0.80146105, 2.33742768],
[ 1.23292342, 1.5878066 , 0.8046354 , 2.02853881, 3.89350446]])
Additionally see : Tips on how to carry out logistic regression?
Random quantity utilizing Log-normal distribution
Syntax = np.random.lognormal(imply,sigma,dimension)
imply is imply of distribution, sigma is normal deviation and dimension is output dimension.
np.random.lognormal(1.7,3,(4,4))
#output
array([[1.40715174e+00, 4.36289629e+02, 5.39792968e-01, 1.76535312e+01],
[5.00840364e+00, 9.83178228e+01, 1.19607261e+02, 1.78129138e+00],
[2.68650071e+03, 1.13816121e-02, 1.65388345e+02, 2.96574858e+02],
[2.07001722e+00, 9.70251596e+01, 4.27142923e+00,1.47442389e+03]])
Random quantity utilizing logarithmic sequence distribution
Syntax = np.random.logseries(p,dimension)
p = form of parameter and dimension is the output dimension
np.random.logseries(0.3,10)
#output
array([1, 1, 1, 2, 2, 1, 1, 2, 2, 1])
Random quantity utilizing multinomial distribution
Syntax = np.random.multinomial(n,pvals,dimension)
n = Variety of experiments, pvals = possibilities of every of the p completely different outcomes, dimension = output
##INCORRECT WAY**
np.random.multinomial(100,[1.0,2.0])
## CORRECT WAY**
np.random.multinomial(100,[0.33,0.67])
#Output
array([32, 68])
Complete possibilities ought to equate to 1.
Random Quantity utilizing multivariate regular distribution
Syntax = np.random.multivariate_normal(imply, cov, dimension=None, check_valid=’warn’, tol=1e-8)
Imply is common of the distribution, cov is 2-D array of covariance matrix, dimension is output variable.
imply = [0,0]
cov = [[1,0],[0,100]]
np.random.multivariate_normal(imply,cov,25)
#output
array([[ 1.0583769 , -6.73763092],
[ 0.22438227, -0.82776199],
[ 0.09768098, 15.24671877],
[ -0.24181648, -11.48089529],
[ 0.35477317, 17.89635344],
[ -0.904405 , -7.97900411],
[ -0.36658878, 2.84571603],
[ 0.07927533, -4.38038809],
[ 0.38364186, -9.20044877],
[ 0.85900062, -1.60333465],
[ 0.23407273, 0.54900275],
[ 0.14430106, 5.88275667],
[ 0.80327105, -6.42434813],
[ -1.97672621, 6.06341989],
[ -0.03283161, -5.08108659],
[ 0.38615864, -3.54352388],
[ -0.24381702, -2.24203499],
[ -0.8630832 , -5.84384577],
[ -1.50429457, 10.00024101],
[ 0.85881912, -7.85933608],
[ -1.69144074, -0.18711476],
[ 0.14614225, -0.12395603],
[ 0.29826931, 11.82998333],
[ -0.26094534, 1.65119128],
[ -0.96138003, -9.9508009 ]])
Random Quantity from Destructive Binomial Distribution
Syntax : np.random.negative_binomial(n,p,dimension=None)
n = successes and p = chance of success the place n > 0 , dimension = output
np.random.negative_binomial(20,0.6,20)
#output
array([12, 11, 15, 13, 5, 20, 18, 16, 10, 10, 15, 18, 9, 14, 15, 11, 12,20, 7, 12])
Random Quantity from non central chi-square distribution
Syntax = np.random.noncentral_chisquare(df, nonc,dimension)
df is diploma of freedom, nonc = Non-centrality, dimension = output dimension
np.random.noncentral_chisquare(3,1.25,20)
#output
array([ 3.2502257 , 3.89533858, 0.69266479, 3.58683562, 6.11163544,
7.62056822, 6.98963657, 9.28862215, 0.46781792, 6.10301397,
2.01091728, 3.64487203, 10.04375102, 0.44140926, 7.75791933,
7.40398072, 1.49594865, 1.6596545 , 5.65977098, 2.60366886])
Random Quantity from non central f distribution
Syntax = np.random.noncentral_f(dfnum, dfden, nonc, dimension=None)
dfnum is diploma of freedom for numerator, dfden is diploma of freedom for denominator, nonc = Non-centrality (should be a floating quantity) , dimension = output dimension
np.random.noncentral_f(dfnum=3, dfden=5, nonc=1.25, dimension=15)
#Output
array([2.82181973, 0.2621002 , 4.61560275, 0.92404405, 0.5873313 ,
1.33722611, 4.23087649, 1.55502861, 0.13974765, 0.61263875,
0.02363684, 5.08036131, 1.69583817, 1.16514151, 7.26156769])
Random Quantity from regular distribution
Syntax = np.random.regular(loc=0.0, scale=1.0, dimension=None)
loc = imply of distribution, scale = normal deviation, dimension = output dimension
np.random.regular(2,1.5,20)
#output
array([1.22878811, 1.76942276, 2.82803968, 4.24962168, 3.51949639,
1.34530222, 3.19609968, 1.81777226, 1.60022974, 0.73742226,
2.47042775, 3.72900064, 1.85292514, 2.06721983, 2.90782025,
5.04814424, 3.59360224, 0.64323389, 1.96419374, 1.09703602])
Random Quantity from Pareto II or Lomax Distribution
Syntax = np.random.pareto(a,dimension)
a is form of distribution, dimension is output dimension
np.random.pareto(2.1,50)
#output
array([0.20190563, 0.59110505, 0.75834325, 1.64327581, 0.18154189,
0.27552696, 0.15482498, 1.62308317, 0.40219138, 1.32101952,
0.66438345, 0.49743756, 0.17669289, 0.54696228, 0.03728383,
0.47179657, 0.12612053, 1.1286781 , 0.21520764, 0.70700926,
0.28114239, 0.15643503, 0.04762157, 0.93122826, 0.15392584,
0.80165583, 1.26344098, 0.50648548, 0.4513544 , 0.21481885,
0.23661846, 0.46451604, 0.07339994, 0.76501248, 1.31005359,
0.45282259, 0.36370636, 0.08363621, 0.32064526, 0.14687389,
0.08148094, 0.12367398, 0.39541968, 2.1171226 , 6.21913449,
0.72456524, 0.41744179, 0.17453438, 0.53098405, 0.2464528 ])
Random Quantity from Permutation
Syntax = np.random.permutation(a)
a is the multi-dimensional array which is returned
np.random.permutation(15)
#Output
array([ 4, 13, 7, 5, 2, 3, 10, 14, 12, 6, 1, 9, 0, 8, 11])
Random Quantity from Poisson Distribution
Syntax = np.random.poisson(lambda,dimension)
lambda is expectation of interval, a sequence of expectation intervals which should be broadcast-able over the requested dimension. Measurement is output dimension.
np.random.poisson(1.25,15)
#output
array([0, 1, 0, 1, 1, 1, 2, 0, 2, 0, 0, 1, 2, 2, 0])
Random Quantity with Energy operate Distribution
Syntax = np.random.energy(a, dimension=None)
Attracts samples in [0,1] from an influence distribution with constructive exponent a-1
a is parameter of distribution.
np.random.energy(2,10)
#output
array([0.64610162, 0.90615695, 0.80111382, 0.83723759, 0.95385319,
0.65986407, 0.52173754, 0.44076093, 0.70683377, 0.25296038])
Random values in a given form
Syntax = np.random.rand(form)
form is what output you’re looking. It’s a very helpful operate the place you simply need generate random numbers in any form between 0 and 1.
Instance 1
np.random.rand(5)
#output
array([0.31979732, 0.1021601 , 0.68860515, 0.95345352, 0.76700075])
Instance 2
np.random.rand(5,5)
#output
array([[0.89496089, 0.19831118, 0.82093535, 0.38698579, 0.45182078],
[0.3173055 , 0.47643795, 0.02411467, 0.41312906, 0.45766815],
[0.19939672, 0.61164512, 0.97380032, 0.34729909, 0.57582168],
[0.43693548, 0.99888766, 0.08155983, 0.2058013 , 0.25305034],
[0.48938304, 0.57166518, 0.19046207, 0.33510041, 0.8302206 ]])
Random integers in a any form
Syntax = np.random.randint(low,excessive,dimension,dtype)
low = decrease worth of the array, excessive = increased worth of the array, dimension = dimension of array, dtype is non-obligatory which represents information kind, default is integer.
Instance 1
np.random.randint(3,99,5)
#output
array([65, 82, 64, 87, 94])
Instance 2
np.random.randint(0,99,(10,5))
#output
array([[37, 67, 16, 71, 86],
[76, 93, 47, 7, 5],
[51, 94, 15, 80, 95],
[16, 60, 58, 39, 34],
[16, 7, 49, 3, 81],
[32, 56, 46, 1, 92],
[21, 46, 38, 10, 67],
[60, 5, 11, 0, 4],
[50, 48, 4, 47, 85],
[48, 2, 55, 88, 16]])
Random numbers with normal regular distribution
Syntax = np.random.randn(dimension)
Instance 1
np.random.randn()
#output
0.2517770198240781
Instance 2
np.random.randn(10)
#output
array([ 0.03536071, -0.73462545, 0.72335424, 1.06593006, -0.05144373,
0.62629189, 0.63594877, 0.21805066, 0.32423357, 0.99847683])
Instance 3
np.random.randn(3,3)
#output
array([[ 0.41454857, -0.46739665, 0.09379884],
[-0.11549637, -0.45300003, 1.25859377],
[ 1.17715926, 1.11386284, 0.016956 ]])
Random numbers with random operate in numpy
np.random.random(10)
#output
array([0.4903158 , 0.58125484, 0.17943641, 0.68877055, 0.67935105,
0.15904048, 0.99928076, 0.97126629, 0.5118656 , 0.98872158])
Random numbers with random integer
Syntax = np.random.random_integers(low,excessive,dimension)
np.random.random_integers(100,299,5)
#output
array([249, 145, 279, 297, 275])
Random numbers with random pattern operate
Syntax = np.random.random_sample(dimension)
Returns random floats in half-open interval between [0.0,1.0] from steady uniform distribution over acknowledged interval.
np.random.random_sample(3)
#Output
array([0.7316707 , 0.47935491, 0.32710002])
Random numbers with random_sample utilizing ranf operate
Much like operate above.
np.random.ranf()
#output
0.5021778121999729
Random numbers with Rayleigh distribution
Syntax = np.random.rayleigh(scale,dimension)
Scale is the same as mode, and dimension is output.
np.random.rayleigh(4,25)
#output
array([3.67644931, 9.94228797, 5.11367837, 6.89794945, 4.58289571,
5.16278338, 9.91446273, 6.67583764, 4.01852172, 5.0486583 ,
7.01808964, 6.67599884, 1.95575305, 3.30532575, 6.93801153,
2.93501618, 2.52539008, 2.26931366, 7.5955984 , 5.77528647,
1.98386752, 7.6333883 , 3.08630146, 3.7055877 , 1.9142021 ])
Additionally see: numpy documentation
Random Quantity with Random Pattern
Syntax = np.random.pattern(dimension)
Much like operate above np.random.random_sample(dimension).
np.random.pattern((2,3))
#output
array([[0.81662013, 0.42587302, 0.81124033],
[0.21839886, 0.77857156, 0.5544037 ]])
Random Quantity with Normal Exponential Distribution
Syntax = np.random.standard_exponential(dimension)
np.random.standard_exponential(25)
#output
array([1.69517629, 0.47092373, 1.44504697, 1.62253902, 2.45741137,
3.5907787 , 1.43963212, 2.73247868, 0.42686694, 0.78592606,
2.06899199, 1.84675837, 0.18881986, 0.14831924, 0.16521402,
0.30789576, 0.24062331, 3.86271815, 0.04647824, 2.17968715,
1.58989665, 1.32899491, 0.2824693 , 0.34574499, 0.49977064])
Random Quantity with Normal Gamma Distribution
Syntax = np.random.standard_gamma(form,dimension)
np.random.standard_gamma(2,25)
#output
array([1.47489475, 0.98783585, 3.06439039, 2.70299078, 1.00125724,
3.41321207, 1.45316889, 1.37849927, 2.17417734, 1.02550514,
3.14293683, 0.75427569, 1.39733355, 3.02742645, 2.52080741,
1.58087858, 0.9321168 , 0.35499143, 1.56586845, 2.66629806,
0.26594377, 2.64386605, 2.47724875, 0.74633522, 1.4379539 ])
Random Quantity with Normal Regular Distribution
Syntax = np.random.standard_normal(dimension)
np.random.standard_normal(25)
#output
array([-0.50411918, -0.19242669, -1.04301891, -2.86600993, -0.17821729,
-1.78844535, 0.01149429, -0.6465523 , 1.15275553, -0.6628385 ,
1.06259585, 0.47259713, -0.2362869 , 0.92190467, -0.07809203,
-0.87478794, 0.59850114, 1.240925 , 1.43693503, 1.77895149,
-0.17604199, -0.5622008 , -0.46776274, -0.70779913, 0.64111016])
Random Quantity with Scholar’s t distribution
Syntax = np.random.standard_t(df,dimension)
df = diploma of freedom, dimension = output dimension
np.random.standard_t(4,20)
#output
array([-0.03761931, -0.53542011, -0.82226061, 2.77274927, 1.36305114,
0.84279241, -0.96051502, -0.931811 , -1.97582607, 0.90238034,
-2.6591602 , -0.18514808, 1.38443011, -2.47352668, -0.72479415,
-0.46394313, 0.36501484, 0.02600794, 0.43280882, 3.11579655])
Random Quantity with triangular distribution
Syntax = np.random.triangular(left, mode, proper, dimension)
left = Decrease restrict, mode = worth the place the height of the distribution happens, proper = higher restrict proper, dimension = output dimension
np.random.triangular(5,7,100,15)
#output
array([72.68841636, 6.65466674, 37.06365392, 11.63499808, 57.02612156,
17.0242832 , 13.73246187, 30.32347587, 16.87209818, 48.98226813,
78.53673426, 21.8907941 , 39.07014104, 63.39904707, 7.24041671])
Random Quantity with Uniform distribution
Syntax = np.random.uniform(low,excessive,dimension)
low = Decrease boundary of the output interval, excessive = higher boundary of the output interval, dimension = output dimension
np.random.uniform(-1,0,50)
#output
array([-0.64268341, -0.74053593, -0.86083515, -0.97827256, -0.51694037,
-0.59724899, -0.22997751, -0.62904188, -0.55550559, -0.04669756,
-0.82999905, -0.81940136, -0.39446351, -0.0900903 , -0.79935745,
-0.45949614, -0.08793975, -0.02514434, -0.04882844, -0.21993363,
-0.67682675, -0.39012145, -0.12231128, -0.80351525, -0.79027821,
-0.68504266, -0.7727574 , -0.92828025, -0.76424453, -0.58502038,
-0.31298751, -0.84655515, -0.98427394, -0.52427507, -0.64146536,
-0.67315909, -0.70913881, -0.07703927, -0.29066913, -0.93916588,
-0.71678679, -0.02948388, -0.33285311, -0.65812366, -0.17100715,
-0.57682746, -0.55373444, -0.9078292 , -0.80681998, -0.98358159])
Random Quantity with von Mises distribution
Syntax = np.random.vonmises(mu,kappa,dimension)
mu = specified mode, dispersion = kappa, dimension = output dimension
np.random.vonmises(0.0,4.0,50)
#output
array([ 0.50617877, -0.55452707, 0.27166358, 0.71364853, 0.27206078,
-0.15113751, 0.60714844, -0.0130119 , 0.60827732, -0.22046848,
-0.67843826, 0.64373078, 0.15314237, 0.84476529, 0.98953813,
-0.39908337, 0.018111 , 0.3438166 , -0.63038277, 0.27033356,
-0.55090202, -1.55379684, -0.04810806, -0.55263185, -0.09612684,
-0.11469079, -0.15333622, 0.16536455, 0.11557599, 0.41025531,
-0.11924513, -0.5580775 , 0.21323462, -0.3326264 , -0.20208534,
-0.98845445, 0.82418154, 0.4292819 , -0.85179192, -0.2586714 ,
-0.19871269, -0.26012258, 0.53805736, -0.35569167, 0.51900356,
-0.37224398, 0.44752048, -0.28595452, 0.77041203, -0.90461881])
Random Quantity with Inverse Gaussian distribution
Syntax = np.random.wald(imply,scale,dimension)
imply = Distribution imply, scale = scale parameter, dimension = output dimension
np.random.wald(3,2,50)
#output
array([ 1.97549667, 11.26064826, 8.70373063, 1.49919266, 2.84646702,
1.40979166, 1.56678586, 0.94830844, 3.97835217, 1.65001748,
2.49561189, 15.09240892, 3.71636539, 0.27824736, 0.95091593,
2.65145655, 2.31379872, 4.94456475, 0.4775645 , 7.27376631,
5.14880819, 0.38928344, 3.9154816 , 1.09056632, 2.93012853,
1.67842202, 1.48898819, 2.3333528 , 3.51157375, 3.4186573 ,
3.29084717, 3.99499236, 2.56147852, 1.70156073, 0.69196234,
3.04916012, 0.70794518, 4.65647486, 2.85268278, 0.69920353,
1.52131512, 0.36320725, 3.54216966, 1.04346084, 0.78706312,
2.62193571, 1.38874333, 2.50067812, 3.87996779, 1.31290062])
Random Quantity with Weibull distribution
Syntax = np.random.weibull(a, dimension)
a = form parameter of distribution, dimension = output dimension
np.random.weibull(5,25)
#output
array([0.95978632, 0.57013906, 1.05159918, 1.15938788, 1.05659862,
0.8749593 , 0.74393834, 0.85097397, 0.73128897, 0.98803254,
0.63087803, 0.75932433, 1.07971653, 0.48543824, 0.86043331,
0.99059255, 0.78462769, 0.8260131 , 0.96776262, 1.03777549,
0.55656863, 0.58452842, 0.67127651, 0.89608467, 1.01369933])
Random Quantity with Zipf distribution
Syntax = np.random.zipf(a, dimension)
a = Distribution parameter, dimension = output dimension
np.random.zipf(3,25)
#output
array([1, 3, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 4, 3, 1, 1, 1, 3, 1, 1, 1,
1, 1, 1])
Extra random quantity generator in python coming quickly…
[ad_2]