Demand distribution

Working with distributions is very convinient in Julia. This package is supposed to work with any univariate distribution from the Distributions.jl package.

For example, consider a slight variation of the introductory example. Suppose we want to avoid demand below zero, i.e., let us truncate the distribution at 0. We can define our distribution of choice as follows:

julia> my_distr = truncated(Normal(50, 20), 0, Inf)
Truncated(Normal{Float64}(μ=50.0, σ=20.0); lower=0.0)

The model is now defined and stored in the variable nvm2 as follows:

julia> nvm2 = NVModel(demand = my_distr, cost = 5, price = 7)
Data of the Newsvendor Model
 * Demand distribution: Truncated(Normal{Float64}(μ=50.0, σ=20.0); lower=0.0)
 * Unit cost: 5.00
 * Unit selling price: 7.00

Optimization yields a slightly different result:

julia> profit(solve(nvm2)) - profit(solve(NVModel(demand = Normal(50, 20), cost = 5, price = 7)))
1.8282476501980582

Other typical distributions are readily available, e.g.,

Moreover, it is convinient to fit distributions with Distributions.jl.