@stdlib/random-array 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,31 +18,52 @@
18
18
 
19
19
  // TypeScript Version: 4.1
20
20
 
21
- /* tslint:disable:max-line-length */
22
- /* tslint:disable:max-file-line-count */
21
+ /* eslint-disable max-lines */
23
22
 
24
23
  import arcsine = require( '@stdlib/random-array-arcsine' );
24
+ import bernoulli = require( '@stdlib/random-array-bernoulli' );
25
25
  import beta = require( '@stdlib/random-array-beta' );
26
26
  import betaprime = require( '@stdlib/random-array-betaprime' );
27
+ import binomial = require( '@stdlib/random-array-binomial' );
28
+ import cauchy = require( '@stdlib/random-array-cauchy' );
29
+ import chi = require( '@stdlib/random-array-chi' );
30
+ import chisquare = require( '@stdlib/random-array-chisquare' );
27
31
  import cosine = require( '@stdlib/random-array-cosine' );
28
32
  import discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
33
+ import erlang = require( '@stdlib/random-array-erlang' );
29
34
  import exponential = require( '@stdlib/random-array-exponential' );
35
+ import f = require( '@stdlib/random-array-f' );
36
+ import frechet = require( '@stdlib/random-array-frechet' );
30
37
  import gamma = require( '@stdlib/random-array-gamma' );
38
+ import geometric = require( '@stdlib/random-array-geometric' );
39
+ import gumbel = require( '@stdlib/random-array-gumbel' );
40
+ import hypergeometric = require( '@stdlib/random-array-hypergeometric' );
31
41
  import invgamma = require( '@stdlib/random-array-invgamma' );
42
+ import kumaraswamy = require( '@stdlib/random-array-kumaraswamy' );
43
+ import laplace = require( '@stdlib/random-array-laplace' );
44
+ import levy = require( '@stdlib/random-array-levy' );
45
+ import logistic = require( '@stdlib/random-array-logistic' );
32
46
  import lognormal = require( '@stdlib/random-array-lognormal' );
33
47
  import minstd = require( '@stdlib/random-array-minstd' );
34
48
  import minstdShuffle = require( '@stdlib/random-array-minstd-shuffle' );
35
49
  import mt19937 = require( '@stdlib/random-array-mt19937' );
50
+ import negativeBinomial = require( '@stdlib/random-array-negative-binomial' );
36
51
  import normal = require( '@stdlib/random-array-normal' );
52
+ import pareto1 = require( '@stdlib/random-array-pareto-type1' );
53
+ import poisson = require( '@stdlib/random-array-poisson' );
37
54
  import randu = require( '@stdlib/random-array-randu' );
55
+ import rayleigh = require( '@stdlib/random-array-rayleigh' );
56
+ import t = require( '@stdlib/random-array-t' );
57
+ import triangular = require( '@stdlib/random-array-triangular' );
38
58
  import uniform = require( '@stdlib/random-array-uniform' );
59
+ import weibull = require( '@stdlib/random-array-weibull' );
39
60
 
40
61
  /**
41
62
  * Interface describing the `array` namespace.
42
63
  */
43
64
  interface Namespace {
44
65
  /**
45
- * Returns an array containing pseudorandom numbers drawn from an arcsine distribution with minimum support `a` and maximum support `b`.
66
+ * Returns an array containing pseudorandom numbers drawn from an arcsine distribution.
46
67
  *
47
68
  * @param len - array length
48
69
  * @param a - minimum support
@@ -63,7 +84,27 @@ interface Namespace {
63
84
  arcsine: typeof arcsine;
64
85
 
65
86
  /**
66
- * Returns an array containing pseudorandom numbers drawn from a beta distribution with parameters `alpha` (first shape parameter) and `beta` (second shape parameter).
87
+ * Returns an array containing pseudorandom numbers drawn from a Bernoulli distribution.
88
+ *
89
+ * @param len - array length
90
+ * @param p - success probability
91
+ * @param options - function options
92
+ * @returns output array
93
+ *
94
+ * @example
95
+ * var out = ns.bernoulli( 10, 0.5 );
96
+ * // returns <Float64Array>
97
+ *
98
+ * @example
99
+ * var random = ns.bernoulli.factory( 0.5 );
100
+ *
101
+ * var out = random( 10 );
102
+ * // returns <Float64Array>
103
+ */
104
+ bernoulli: typeof bernoulli;
105
+
106
+ /**
107
+ * Returns an array containing pseudorandom numbers drawn from a beta distribution.
67
108
  *
68
109
  * @param len - array length
69
110
  * @param alpha - first shape parameter
@@ -84,7 +125,7 @@ interface Namespace {
84
125
  beta: typeof beta;
85
126
 
86
127
  /**
87
- * Returns an array containing pseudorandom numbers drawn from a beta prime distribution with parameters `alpha` (first shape parameter) and `beta` (second shape parameter).
128
+ * Returns an array containing pseudorandom numbers drawn from a beta prime distribution.
88
129
  *
89
130
  * @param len - array length
90
131
  * @param alpha - first shape parameter
@@ -105,7 +146,89 @@ interface Namespace {
105
146
  betaprime: typeof betaprime;
106
147
 
107
148
  /**
108
- * Returns an array containing pseudorandom numbers drawn from a raised cosine distribution with parameters `mu` (mean) and `s` (scale parameter).
149
+ * Returns an array containing pseudorandom numbers drawn from a binomial distribution.
150
+ *
151
+ * @param len - array length
152
+ * @param n - number of trials
153
+ * @param p - success probability
154
+ * @param options - function options
155
+ * @returns output array
156
+ *
157
+ * @example
158
+ * var out = ns.binomial( 10, 17, 0.5 );
159
+ * // returns <Float64Array>
160
+ *
161
+ * @example
162
+ * var random = ns.binomial.factory( 17, 0.5 );
163
+ *
164
+ * var out = random( 10 );
165
+ * // returns <Float64Array>
166
+ */
167
+ binomial: typeof binomial;
168
+
169
+ /**
170
+ * Returns an array containing pseudorandom numbers drawn from a Cauchy distribution.
171
+ *
172
+ * @param len - array length
173
+ * @param x0 - location parameter
174
+ * @param gamma - scale parameter
175
+ * @param options - function options
176
+ * @returns output array
177
+ *
178
+ * @example
179
+ * var out = ns.cauchy( 10, 2.0, 5.0 );
180
+ * // returns <Float64Array>
181
+ *
182
+ * @example
183
+ * var random = ns.cauchy.factory( 2.0, 5.0 );
184
+ *
185
+ * var out = random( 10 );
186
+ * // returns <Float64Array>
187
+ */
188
+ cauchy: typeof cauchy;
189
+
190
+ /**
191
+ * Returns an array containing pseudorandom numbers drawn from a chi distribution.
192
+ *
193
+ * @param len - array length
194
+ * @param k - degrees of freedom
195
+ * @param options - function options
196
+ * @returns output array
197
+ *
198
+ * @example
199
+ * var out = ns.chi( 10, 2.0 );
200
+ * // returns <Float64Array>
201
+ *
202
+ * @example
203
+ * var random = ns.chi.factory( 2.0 );
204
+ *
205
+ * var out = random( 10 );
206
+ * // returns <Float64Array>
207
+ */
208
+ chi: typeof chi;
209
+
210
+ /**
211
+ * Returns an array containing pseudorandom numbers drawn from a chi-square distribution.
212
+ *
213
+ * @param len - array length
214
+ * @param k - degrees of freedom
215
+ * @param options - function options
216
+ * @returns output array
217
+ *
218
+ * @example
219
+ * var out = ns.chisquare( 10, 2.0 );
220
+ * // returns <Float64Array>
221
+ *
222
+ * @example
223
+ * var random = ns.chisquare.factory( 2.0 );
224
+ *
225
+ * var out = random( 10 );
226
+ * // returns <Float64Array>
227
+ */
228
+ chisquare: typeof chisquare;
229
+
230
+ /**
231
+ * Returns an array containing pseudorandom numbers drawn from a raised cosine distribution.
109
232
  *
110
233
  * @param len - array length
111
234
  * @param mu - mean
@@ -126,7 +249,7 @@ interface Namespace {
126
249
  cosine: typeof cosine;
127
250
 
128
251
  /**
129
- * Returns an array containing pseudorandom numbers drawn from a discrete uniform distribution with minimum support `a` and maximum support `b`.
252
+ * Returns an array containing pseudorandom numbers drawn from a discrete uniform distribution.
130
253
  *
131
254
  * @param len - array length
132
255
  * @param a - minimum support
@@ -147,7 +270,28 @@ interface Namespace {
147
270
  discreteUniform: typeof discreteUniform;
148
271
 
149
272
  /**
150
- * Returns an array containing pseudorandom numbers drawn from an exponential distribution with rate parameter `lambda`.
273
+ * Returns an array containing pseudorandom numbers drawn from an Erlang distribution.
274
+ *
275
+ * @param len - array length
276
+ * @param k - shape parameter
277
+ * @param lambda - rate parameter
278
+ * @param options - function options
279
+ * @returns output array
280
+ *
281
+ * @example
282
+ * var out = ns.erlang( 10, 2, 5.0 );
283
+ * // returns <Float64Array>
284
+ *
285
+ * @example
286
+ * var random = ns.erlang.factory( 2, 5.0 );
287
+ *
288
+ * var out = random( 10 );
289
+ * // returns <Float64Array>
290
+ */
291
+ erlang: typeof erlang;
292
+
293
+ /**
294
+ * Returns an array containing pseudorandom numbers drawn from an exponential distribution.
151
295
  *
152
296
  * @param len - array length
153
297
  * @param lambda - rate parameter
@@ -167,7 +311,50 @@ interface Namespace {
167
311
  exponential: typeof exponential;
168
312
 
169
313
  /**
170
- * Returns an array containing pseudorandom numbers drawn from a gamma distribution with parameters `alpha` (shape parameter) and `beta` (rate parameter).
314
+ * Returns an array containing pseudorandom numbers drawn from an F distribution.
315
+ *
316
+ * @param len - array length
317
+ * @param d1 - degrees of freedom
318
+ * @param d2 - degrees of freedom
319
+ * @param options - function options
320
+ * @returns output array
321
+ *
322
+ * @example
323
+ * var out = ns.f( 10, 2.0, 5.0 );
324
+ * // returns <Float64Array>
325
+ *
326
+ * @example
327
+ * var random = ns.f.ns.factory( 2.0, 5.0 );
328
+ *
329
+ * var out = random( 10 );
330
+ * // returns <Float64Array>
331
+ */
332
+ f: typeof f;
333
+
334
+ /**
335
+ * Returns an array containing pseudorandom numbers drawn from a Fréchet distribution.
336
+ *
337
+ * @param len - array length
338
+ * @param alpha - shape parameter
339
+ * @param s - scale parameter
340
+ * @param m - location parameter
341
+ * @param options - function options
342
+ * @returns output array
343
+ *
344
+ * @example
345
+ * var out = ns.frechet( 10, 2.0, 5.0, 3.0 );
346
+ * // returns <Float64Array>
347
+ *
348
+ * @example
349
+ * var random = ns.frechet.factory( 2.0, 5.0, 3.0 );
350
+ *
351
+ * var out = random( 10 );
352
+ * // returns <Float64Array>
353
+ */
354
+ frechet: typeof frechet;
355
+
356
+ /**
357
+ * Returns an array containing pseudorandom numbers drawn from a gamma distribution.
171
358
  *
172
359
  * @param len - array length
173
360
  * @param alpha - shape parameter
@@ -188,7 +375,70 @@ interface Namespace {
188
375
  gamma: typeof gamma;
189
376
 
190
377
  /**
191
- * Returns an array containing pseudorandom numbers drawn from an inverse gamma distribution with parameters `alpha` (shape parameter) and `beta` (scale parameter).
378
+ * Returns an array containing pseudorandom numbers drawn from a geometric distribution.
379
+ *
380
+ * @param len - array length
381
+ * @param p - success probability
382
+ * @param options - function options
383
+ * @returns output array
384
+ *
385
+ * @example
386
+ * var out = ns.geometric( 10, 0.01 );
387
+ * // returns <Float64Array>
388
+ *
389
+ * @example
390
+ * var random = ns.geometric.factory( 0.01 );
391
+ *
392
+ * var out = random( 10 );
393
+ * // returns <Float64Array>
394
+ */
395
+ geometric: typeof geometric;
396
+
397
+ /**
398
+ * Returns an array containing pseudorandom numbers drawn from a Gumbel distribution.
399
+ *
400
+ * @param len - array length
401
+ * @param mu - mean
402
+ * @param beta - scale parameter
403
+ * @param options - function options
404
+ * @returns output array
405
+ *
406
+ * @example
407
+ * var out = ns.gumbel( 10, 2.0, 5.0 );
408
+ * // returns <Float64Array>
409
+ *
410
+ * @example
411
+ * var random = ns.gumbel.factory( 2.0, 5.0 );
412
+ *
413
+ * var out = random( 10 );
414
+ * // returns <Float64Array>
415
+ */
416
+ gumbel: typeof gumbel;
417
+
418
+ /**
419
+ * Returns an array containing pseudorandom numbers drawn from a hypergeometric distribution.
420
+ *
421
+ * @param len - array length
422
+ * @param N - population size
423
+ * @param K - subpopulation size
424
+ * @param n - number of draws
425
+ * @param options - function options
426
+ * @returns output array
427
+ *
428
+ * @example
429
+ * var out = ns.hypergeometric( 10, 20, 10, 7 );
430
+ * // returns <Float64Array>
431
+ *
432
+ * @example
433
+ * var random = ns.hypergeometric.factory( 20, 10, 7 );
434
+ *
435
+ * var out = random( 10 );
436
+ * // returns <Float64Array>
437
+ */
438
+ hypergeometric: typeof hypergeometric;
439
+
440
+ /**
441
+ * Returns an array containing pseudorandom numbers drawn from an inverse gamma distribution.
192
442
  *
193
443
  * @param len - array length
194
444
  * @param alpha - shape parameter
@@ -209,7 +459,91 @@ interface Namespace {
209
459
  invgamma: typeof invgamma;
210
460
 
211
461
  /**
212
- * Returns an array containing pseudorandom numbers drawn from a lognormal distribution with parameters `mu` (location parameter) and `sigma` (scale parameter).
462
+ * Returns an array containing pseudorandom numbers drawn from Kumaraswamy's double bounded distribution.
463
+ *
464
+ * @param len - array length
465
+ * @param a - first shape parameter
466
+ * @param b - second shape parameter
467
+ * @param options - function options
468
+ * @returns output array
469
+ *
470
+ * @example
471
+ * var out = ns.kumaraswamy( 10, 2.0, 5.0 );
472
+ * // returns <Float64Array>
473
+ *
474
+ * @example
475
+ * var random = ns.kumaraswamy.factory( 2.0, 5.0 );
476
+ *
477
+ * var out = random( 10 );
478
+ * // returns <Float64Array>
479
+ */
480
+ kumaraswamy: typeof kumaraswamy;
481
+
482
+ /**
483
+ * Returns an array containing pseudorandom numbers drawn from a Laplace (double exponential) distribution.
484
+ *
485
+ * @param len - array length
486
+ * @param mu - mean
487
+ * @param b - scale parameter
488
+ * @param options - function options
489
+ * @returns output array
490
+ *
491
+ * @example
492
+ * var out = ns.laplace( 10, 2.0, 5.0 );
493
+ * // returns <Float64Array>
494
+ *
495
+ * @example
496
+ * var random = ns.laplace.factory( 2.0, 5.0 );
497
+ *
498
+ * var out = random( 10 );
499
+ * // returns <Float64Array>
500
+ */
501
+ laplace: typeof laplace;
502
+
503
+ /**
504
+ * Returns an array containing pseudorandom numbers drawn from a Lévy distribution.
505
+ *
506
+ * @param len - array length
507
+ * @param mu - location parameter
508
+ * @param c - scale parameter
509
+ * @param options - function options
510
+ * @returns output array
511
+ *
512
+ * @example
513
+ * var out = ns.levy( 10, 2.0, 5.0 );
514
+ * // returns <Float64Array>
515
+ *
516
+ * @example
517
+ * var random = ns.levy.factory( 2.0, 5.0 );
518
+ *
519
+ * var out = random( 10 );
520
+ * // returns <Float64Array>
521
+ */
522
+ levy: typeof levy;
523
+
524
+ /**
525
+ * Returns an array containing pseudorandom numbers drawn from a logistic distribution.
526
+ *
527
+ * @param len - array length
528
+ * @param mu - mean parameter
529
+ * @param s - scale parameter
530
+ * @param options - function options
531
+ * @returns output array
532
+ *
533
+ * @example
534
+ * var out = ns.logistic( 10, 2.0, 5.0 );
535
+ * // returns <Float64Array>
536
+ *
537
+ * @example
538
+ * var random = ns.logistic.factory( 2.0, 5.0 );
539
+ *
540
+ * var out = random( 10 );
541
+ * // returns <Float64Array>
542
+ */
543
+ logistic: typeof logistic;
544
+
545
+ /**
546
+ * Returns an array containing pseudorandom numbers drawn from a lognormal distribution.
213
547
  *
214
548
  * @param len - array length
215
549
  * @param mu - location parameter
@@ -299,7 +633,28 @@ interface Namespace {
299
633
  mt19937: typeof mt19937;
300
634
 
301
635
  /**
302
- * Returns an array containing pseudorandom numbers drawn from a normal distribution with parameters `mu` (mean) and `sigma` (standard deviation).
636
+ * Returns an array containing pseudorandom numbers drawn from a negative binomial distribution.
637
+ *
638
+ * @param len - array length
639
+ * @param r - number of successes until experiment is stopped
640
+ * @param p - success probability
641
+ * @param options - function options
642
+ * @returns output array
643
+ *
644
+ * @example
645
+ * var out = ns.negativeBinomial( 10, 10, 0.5 );
646
+ * // returns <Float64Array>
647
+ *
648
+ * @example
649
+ * var random = ns.negativeBinomial.factory( 10, 0.5 );
650
+ *
651
+ * var out = random( 10 );
652
+ * // returns <Float64Array>
653
+ */
654
+ negativeBinomial: typeof negativeBinomial;
655
+
656
+ /**
657
+ * Returns an array containing pseudorandom numbers drawn from a normal distribution.
303
658
  *
304
659
  * @param len - array length
305
660
  * @param mu - mean
@@ -319,6 +674,47 @@ interface Namespace {
319
674
  */
320
675
  normal: typeof normal;
321
676
 
677
+ /**
678
+ * Returns an array containing pseudorandom numbers drawn from a Pareto (Type I) distribution.
679
+ *
680
+ * @param len - array length
681
+ * @param alpha - shape parameter
682
+ * @param beta - scale parameter
683
+ * @param options - function options
684
+ * @returns output array
685
+ *
686
+ * @example
687
+ * var out = ns.pareto1( 10, 2.0, 5.0 );
688
+ * // returns <Float64Array>
689
+ *
690
+ * @example
691
+ * var random = ns.pareto1.factory( 2.0, 5.0 );
692
+ *
693
+ * var out = random( 10 );
694
+ * // returns <Float64Array>
695
+ */
696
+ pareto1: typeof pareto1;
697
+
698
+ /**
699
+ * Returns an array containing pseudorandom numbers drawn from a Poisson distribution.
700
+ *
701
+ * @param len - array length
702
+ * @param lambda - mean parameter
703
+ * @param options - function options
704
+ * @returns output array
705
+ *
706
+ * @example
707
+ * var out = ns.poisson( 10, 2.0 );
708
+ * // returns <Float64Array>
709
+ *
710
+ * @example
711
+ * var random = ns.poisson.factory( 2.0 );
712
+ *
713
+ * var out = random( 10 );
714
+ * // returns <Float64Array>
715
+ */
716
+ poisson: typeof poisson;
717
+
322
718
  /**
323
719
  * Returns an array containing uniformly distributed pseudorandom numbers between `0` and `1`.
324
720
  *
@@ -339,7 +735,69 @@ interface Namespace {
339
735
  randu: typeof randu;
340
736
 
341
737
  /**
342
- * Returns an array containing pseudorandom numbers drawn from a continuous uniform distribution with minimum support `a` and maximum support `b`.
738
+ * Returns an array containing pseudorandom numbers drawn from a Rayleigh distribution.
739
+ *
740
+ * @param len - array length
741
+ * @param sigma - scale parameter
742
+ * @param options - function options
743
+ * @returns output array
744
+ *
745
+ * @example
746
+ * var out = ns.rayleigh( 10, 2.0 );
747
+ * // returns <Float64Array>
748
+ *
749
+ * @example
750
+ * var random = ns.rayleigh.factory( 2.0 );
751
+ *
752
+ * var out = random( 10 );
753
+ * // returns <Float64Array>
754
+ */
755
+ rayleigh: typeof rayleigh;
756
+
757
+ /**
758
+ * Returns an array containing pseudorandom numbers drawn from a Student's t-distribution.
759
+ *
760
+ * @param len - array length
761
+ * @param v - degrees of freedom
762
+ * @param options - function options
763
+ * @returns output array
764
+ *
765
+ * @example
766
+ * var out = ns.t( 10, 2.0 );
767
+ * // returns <Float64Array>
768
+ *
769
+ * @example
770
+ * var random = ns.t.factory( 2.0 );
771
+ *
772
+ * var out = random( 10 );
773
+ * // returns <Float64Array>
774
+ */
775
+ t: typeof t;
776
+
777
+ /**
778
+ * Returns an array containing pseudorandom numbers drawn from a triangular distribution.
779
+ *
780
+ * @param len - array length
781
+ * @param a - minimum support
782
+ * @param b - maximum support
783
+ * @param c - mode
784
+ * @param options - function options
785
+ * @returns output array
786
+ *
787
+ * @example
788
+ * var out = ns.triangular( 10, 2.0, 5.0, 3.0 );
789
+ * // returns <Float64Array>
790
+ *
791
+ * @example
792
+ * var random = ns.triangular.factory( 2.0, 5.0, 3.0 );
793
+ *
794
+ * var out = random( 10 );
795
+ * // returns <Float64Array>
796
+ */
797
+ triangular: typeof triangular;
798
+
799
+ /**
800
+ * Returns an array containing pseudorandom numbers drawn from a continuous uniform distribution.
343
801
  *
344
802
  * @param len - array length
345
803
  * @param a - minimum support
@@ -358,6 +816,27 @@ interface Namespace {
358
816
  * // returns <Float64Array>
359
817
  */
360
818
  uniform: typeof uniform;
819
+
820
+ /**
821
+ * Returns an array containing pseudorandom numbers drawn from a Weibull distribution.
822
+ *
823
+ * @param len - array length
824
+ * @param k - scale parameter
825
+ * @param lambda - shape parameter
826
+ * @param options - function options
827
+ * @returns output array
828
+ *
829
+ * @example
830
+ * var out = ns.weibull( 10, 2.0, 5.0 );
831
+ * // returns <Float64Array>
832
+ *
833
+ * @example
834
+ * var random = ns.weibull.factory( 2.0, 5.0 );
835
+ *
836
+ * var out = random( 10 );
837
+ * // returns <Float64Array>
838
+ */
839
+ weibull: typeof weibull;
361
840
  }
362
841
 
363
842
  /**