Skip to content

Commit

Permalink
Version 0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
prdm0 committed May 6, 2024
1 parent 8086214 commit 6f70ae0
Show file tree
Hide file tree
Showing 69 changed files with 562 additions and 354 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Imports:
cli,
ggplot2,
glue,
lbfgs,
numDeriv,
purrr,
Rcpp,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ importFrom(ggplot2,scale_y_continuous)
importFrom(ggplot2,theme)
importFrom(glue,glue)
importFrom(graphics,hist)
importFrom(lbfgs,lbfgs)
importFrom(numDeriv,grad)
importFrom(parallel,detectCores)
importFrom(parallel,mclapply)
Expand Down
207 changes: 107 additions & 100 deletions R/accept_reject.r

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion R/plot.r
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#' n = 1000L,
#' f = dbinom,
#' continuous = FALSE,
#' args_f = list(size = 5, prob = 0.5),
#' args_f = list(size = 10, prob = 0.5),
#' xlim = c(0, 10)
#' )
#' plot(x)
Expand Down
2 changes: 1 addition & 1 deletion R/print.r
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#' n = 2000L,
#' f = dbinom,
#' continuous = FALSE,
#' args_f = list(size = 5, prob = 0.5),
#' args_f = list(size = 10, prob = 0.5),
#' xlim = c(0, 10)
#' )
#' print(x)
Expand Down
6 changes: 2 additions & 4 deletions R/qqplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ qqplot <- function(x, ...) {
#' )
#' qqplot(y)
#'
#' @seealso [accept_reject()], [plot.accept_reject()], [inspect()] and
#' @seealso [qqplot.accept_reject()], [accept_reject()], [plot.accept_reject()], [inspect()] and
#' [qqplot()].
#'
#' @importFrom Rcpp evalCpp
Expand All @@ -82,9 +82,7 @@ qqplot.accept_reject <-

continuous <- attr(x, "continuous")
sample_quantiles <- sort(x)

n <- length(x)
p <- seq(1L, n) / (n + 1L)
p <- seq(0, 1, length.out = length(x))
theoretical_quantiles <- quantile(x, probs = p, ...)

df <- data.frame(Theoretical = theoretical_quantiles, Sample = sample_quantiles)
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ In the examples, we use well-known distributions, but it's important to note tha

### Generating discrete observations

As an example, let $X \sim Poisson(\lambda = 0.7)$. We will generate $n = 1000$ observations of $X$ using the acceptance-rejection method, using the `AcceptReject::accept_reject()` function. Note that it is necessary to provide the `xlim` argument. Try to set an upper limit value for which the probability of $X$ assuming that value is zero or very close to zero. In this case, we choose `xlim = c(0, 6)`, where `dpois(x = 6, lambda = 0.7)` is very close to zero (`r dpois(x = 6, lambda = 0.7)`).
As an example, let $X \sim Poisson(\lambda = 0.7)$. We will generate $n = 1000$ observations of $X$ using the acceptance-rejection method, using the `accept_reject()` function. Note that it is necessary to provide the `xlim` argument. Try to set an upper limit value for which the probability of $X$ assuming that value is zero or very close to zero. In this case, we choose `xlim = c(0, 6)`, where `dpois(x = 6, lambda = 0.7)` is very close to zero (`r dpois(x = 6, lambda = 0.7)`).

```{r}
library(AcceptReject)
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ package might be what you need. 🎉

As an example, let $X \sim Poisson(\lambda = 0.7)$. We will generate
$n = 1000$ observations of $X$ using the acceptance-rejection method,
using the `AcceptReject::accept_reject()` function. Note that it is
necessary to provide the `xlim` argument. Try to set an upper limit
value for which the probability of $X$ assuming that value is zero or
very close to zero. In this case, we choose `xlim = c(0, 6)`, where
using the `accept_reject()` function. Note that it is necessary to
provide the `xlim` argument. Try to set an upper limit value for which
the probability of $X$ assuming that value is zero or very close to
zero. In this case, we choose `xlim = c(0, 6)`, where
`dpois(x = 6, lambda = 0.7)` is very close to zero (8.1142728^{-5}).

``` r
Expand Down Expand Up @@ -361,7 +361,7 @@ case_1 <- accept_reject(
xlim = c(0, 6)
)
toc()
#> 0.008 sec elapsed
#> 0.005 sec elapsed

# Specifying the base probability density function
tic()
Expand All @@ -377,7 +377,7 @@ case_2 <- accept_reject(
c = 1.2
)
toc()
#> 0.005 sec elapsed
#> 0.004 sec elapsed

# Visualizing the results
p1 <- plot(case_1)
Expand Down
Binary file modified docs/apple-touch-icon-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/apple-touch-icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/apple-touch-icon-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/apple-touch-icon-60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/apple-touch-icon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
174 changes: 84 additions & 90 deletions docs/articles/accept_reject.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/articles/inspect.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified docs/articles/inspect_files/figure-html/unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pkgdown_sha: ~
articles:
accept_reject: accept_reject.html
inspect: inspect.html
last_built: 2024-05-02T11:05Z
last_built: 2024-05-06T18:42Z

Binary file modified docs/reference/Rplot001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/Rplot002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/accept_reject-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/accept_reject-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6f70ae0

Please sign in to comment.