Skip to content

Solve for parameters of a truncated distribution.

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

BjarkeHautop/solvetruncated

Repository files navigation

solvetruncated

R-CMD-check

Overview

The goal of solvetruncated is to solve for parameters of truncated distributions given desired mean and value of CDF at a point. It does this by numerical optimization.

This is for example useful for when specifying a prior in Bayesian, where your belief is often with respect to a mean and value of CDF at a point.

Installation

You can install the development version of solvetruncated from GitHub with:

# install.packages("devtools")
devtools::install_github("BjarkeHautop/solvetruncated")

Example

Here is an example where we wish to solve for the parameters $(\mu, \sigma)$ of $$X \sim \text{TruncNormal}(\mu, \sigma, a=0, b=\infty),$$ where we wish to have $E[X]=0.5$ and $P(X\leq 0.75)=0.8$.

library(solvetruncated)
solve_truncated_normal(desired_mean = 0.5, x_value = 0.75, desired_prob = 0.8, a = 0, b = Inf)
#> $mu
#> [1] 0.4208603
#> 
#> $sigma
#> [1] 0.3543778

which gives that the parameters should be $(\mu=0.42, \sigma=0.35)$.

About

Solve for parameters of a truncated distribution.

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages