Julia : generating unique random integer array

后端 未结 3 1008
礼貌的吻别
礼貌的吻别 2021-02-19 12:08

I am trying to create 10 element array of unique random integers. However I am unable to create array with unique values. Is there in Julia something like Pythons sample functio

3条回答
  •  被撕碎了的回忆
    2021-02-19 12:47

    There is a sample function in StatsBase:

    using StatsBase
    a = sample(1:100, 10, replace = false)
    

    This will draw a sample of length 10 from 1:100 without replacement.

提交回复
热议问题