Skip to content

Usage for dqrng #1

@rstub

Description

@rstub

It's nice to see dqrng being used. However, I think a slightly different pattern would be appropriate since it is only in Suggests. Right now you have

  requireNamespace('dqrng')
[...]
      #Mixi <- matrix(rnorm(n=x, mean=Means[d], sd=SDs[d]), nrow=AnzPoints[d], ncol=1)   
      #MT 2019/03: das ist die schnelle version fuer den bottleneck
      Mixi <- matrix(dqrng::dqrnorm(n=x, mean=Means[d], sd=SDs[d]), nrow=AnzPoints[d], ncol=1)   

which will fail if dqrng is not installed. Instead you could either go from Suggests to Imports or use the fall-back pattern from Hadley's book

  if (requireNamespace("dqrng", quietly = TRUE)) {
    Mixi <- matrix(dqrng::dqrnorm(n=x, mean=Means[d], sd=SDs[d]), nrow=AnzPoints[d], ncol=1)
  } else {
    Mixi <- matrix(rnorm(n=x, mean=Means[d], sd=SDs[d]), nrow=AnzPoints[d], ncol=1)   
  }

BTW, you might be interested that dqrng also has support for fast sampling. Support for more distribution functions (like lnorm) is planned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions