Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'prob' argument for dqrng::dqsample #45

Open
s3alfisc opened this issue Nov 6, 2021 · 5 comments · May be fixed by #72
Open

'prob' argument for dqrng::dqsample #45

s3alfisc opened this issue Nov 6, 2021 · 5 comments · May be fixed by #72

Comments

@s3alfisc
Copy link

s3alfisc commented Nov 6, 2021

Hi - first of all, thanks for a great package - it speeds up my code quite a bit!

Do you have any plans to support the prob argument in dqrng::dqsample? It would be super beneficial in my use case -
I would like to generate so called 'Mammen weights' for a wild bootstrap, which require such an argument. Right now, I use dqsample for some weights distributions, but have to switch back to sample() for Mammen weights. This in turn causes some trouble with setting a 'global seed' - for Mammen weights, the user of my package would have to set it via set.seed() outside of the bootstrap, and for all other weights use dqrng::dqset.seed() (but of course that is not your problem to solve!)

library(dqrng)

dqrng::dqset.seed(89899807)

n <- 10
mammen_dqrng <- 
  dqrng::dqsample(c(-1, 1) * (sqrt(5) + c(-1, 1))/2, n, replace = TRUE,
                            prob = (sqrt(5) + c(1, -1))/(2 * sqrt(5)))
# Warning message:
#   In dqsample.int(length(x), size, replace, prob) :
#   Using 'prob' is not supported yet. Using default 'sample.int'.
@avraam-inside
Copy link

+1. I need this argument too. Did the author abandon the project?

@rstub
Copy link
Member

rstub commented Dec 29, 2022

duplicate of #18, but I am finally working on this: https://stubner.me/2022/12/roulette-wheel-selection-for-dqrng/

@rstub rstub closed this as completed Dec 29, 2022
@rstub
Copy link
Member

rstub commented Jul 30, 2023

@s3alfisc, @avraam-inside: The code for weighted sampling has been finally merged. Feel free to give it a try. Version 0.3.0.2 should be on https://rstub.r-universe.dev/dqrng soon.

@s3alfisc
Copy link
Author

Amazing, will do! Thanks for notifying me =)

@rstub
Copy link
Member

rstub commented Aug 30, 2023

As noted in #52, there are some more things I need to consider w.r.t. to weighted sampling. I will have to back out that code for now in order to release the other changes that have accumulated.

@rstub rstub reopened this Aug 30, 2023
@rstub rstub linked a pull request Oct 7, 2023 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants