在 Incanter 中生成随机数

发布于 2024-09-24 11:47:52 字数 523 浏览 1 评论 0原文

如何使用来自 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

输什么也不输骨气 2024-10-01 11:47:52

在 Incanter 中,您不需要直接调用 Parallel Colt 来生成随机数。有两种不同的方法。

首先,incter.stats 中有原始的随机数生成器函数:

sample-normal
sample-poisson
sample-uniform
sample-t
sample-net-binomial
sample-binomial
etc..

每个函数都将要生成的值的数量作为其第一个参数,以及用于设置要从中提取的分布参数的可选参数。例如,要从平均值为 -2、sqrt 标准差为 0.5 的正态分布中抽取 100 个值,请执行以下操作:

(use '[incanter core stats])
(sample-normal 100 :mean -2 :sd (sqrt 0.5))

生成随机数的第二种方法是使用 incanter.distributions 命名空间中的函数。

(require '[incanter.distributions :as dist])
(dist/draw (dist/normal-distribution -2 (sqrt 0.5)))

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:

sample-normal
sample-poisson
sample-uniform
sample-t
sample-net-binomial
sample-binomial
etc..

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:

(use '[incanter core stats])
(sample-normal 100 :mean -2 :sd (sqrt 0.5))

The second method for generating random numbers is to use functions in the incanter.distributions namespace.

(require '[incanter.distributions :as dist])
(dist/draw (dist/normal-distribution -2 (sqrt 0.5)))
东走西顾 2024-10-01 11:47:52

liebke 可能已经在这里解决了您特定于域的需求,但重新导入:

1) 确保运行 lein deps

2) import 的语法是 (import [cern .jet.random.tdouble 正常])(import cern.jet.random.tdouble.Normal)

liebke may have addressed your domain-specific need here but re importing:

1) Make sure you run lein deps

2) The syntax for import is (import [cern.jet.random.tdouble Normal]) or (import cern.jet.random.tdouble.Normal)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文