Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I randomly select an item from a Vector in Julia?

Tags:

random

julia

Suppose I have a Vector like:

["Cat", "Dog", "Chicken", "Caribou"]

How can I uniformly randomly select an item?

like image 672
DVNold Avatar asked Dec 30 '22 17:12

DVNold


1 Answers

It's as simple as

v=["Cat", "Dog", "Chicken", "Caribou"]
rand(v)
like image 55
Oscar Smith Avatar answered Feb 12 '23 06:02

Oscar Smith