在 Incanter 中生成随机数
如何使用来自 incanter 的 Parallel Colt 中的随机数生成器?
我已在我的project.clj 文件中列出了这些依赖项:
:dependencies [
[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
[incanter/core "1.2.3"]
[incanter/parallelcolt "0.9.4"]
]
然后我尝试了(import cern.jet.random.tdouble Normal)
并得到了class java.lang.ClassNotFoundException
代码>.
我在这里做错了什么?
How do I use the random number generators in Parallel Colt from incanter?
I've listed these dependencies in my project.clj file:
:dependencies [
[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
[incanter/core "1.2.3"]
[incanter/parallelcolt "0.9.4"]
]
And then I tried (import cern.jet.random.tdouble Normal)
and I get a class java.lang.ClassNotFoundException
.
What am I doing wrong here?
在 Incanter 中,您不需要直接调用 Parallel Colt 来生成随机数。有两种不同的方法。
首先,incter.stats 中有原始的随机数生成器函数:
每个函数都将要生成的值的数量作为其第一个参数,以及用于设置要从中提取的分布参数的可选参数。例如,要从平均值为 -2、sqrt 标准差为 0.5 的正态分布中抽取 100 个值,请执行以下操作:
生成随机数的第二种方法是使用 incanter.distributions 命名空间中的函数。
You don't need to call Parallel Colt directly to generate random numbers in Incanter. There are two different methods.
First, there is the original random number generator functions in incanter.stats:
Each function takes the number of values to generate, as its first argument, as well as optional args for setting the parameters of the distribution to draw from. For instance, to draw 100 values from a normal distribution with a mean of -2 and a standard deviation of sqrt of 0.5, do this:
The second method for generating random numbers is to use functions in the incanter.distributions namespace.