How to use the pickRandom function from mathjs

Find comprehensive JavaScript mathjs.pickRandom code examples handpicked from public code repositorys.

61
62
63
64
65
66
67
68
69
70
            len = 4000;
            type = "max";         
        }
    })*/
     //   console.log(m.pickRandom(Object.keys(_this.methods)), type, len, opts)
        var ctx = m.pickRandom(Object.keys(_this.methods))
        return _this.methods[ctx].apply(_this.tContexts[ctx], [opts]);
};

_this.load = function(file) {
fork icon2
star icon14
watch icon5

74
75
76
77
78
79
80
81
82
83
// probability
math.combinations(7, 5) // number of ways picking 'k' unordered outcomes from 'n' possibilities
math.combinationsWithRep(7, 5) // combinations with replacement
math.factorial(a);
math.permutations(n) // number of possible ordered combinations
math.pickRandom(numbers) // random selection from array
math.randomInt(0, 11) // random int (min <= x < max)

// linalg
// https://mathjs.org/docs/reference/functions.html#matrix-functions
fork icon0
star icon3
watch icon0

+ 6 other calls in file

91
92
93
94
95
96
97
98
99
100
this.functions = this.buildFunctionsArray();


  this.functionMapX  = new Array(1);
      for(var i=0; i<this.functionMapX.length; i++){
        this.functionMapX[i] = Mathjs.pickRandom(this.functions);
  }

  this.functionMapY  = new Array(1);
      for(var i=0; i<this.functionMapY.length; i++){
fork icon0
star icon1
watch icon1

+ 15 other calls in file

13
14
15
16
17
18
19
20
21
22
/**
 * x(t+1) = x(t) + ø * (x(t) - randx)
 */
explore() {
    if (this.trial <= config.abc.max_trials) {
        let component = mathjs.pickRandom(this.position);
        let phi       = mathjs.random([1, dimensions], -1, 1)[0];

        let sub             = mathjs.subtract(this.position, component);
        let mul             = mathjs.dotMultiply(sub, phi);
fork icon0
star icon0
watch icon0

12
13
14
15
16
17
18
19
20
21

/**
 * x(t+1) = x(t) + ø * (x(t) - randx)
 */
exploit(sources) {
    let bee         = mathjs.pickRandom(sources);
    let position    = bee.position;
    let fitness     = bee.fitness;

    if (this.trial <= config.abc.max_trials) {
fork icon0
star icon0
watch icon0

+ 3 other calls in file