A fulfilment centre buys units at cost before demand is known, sells them at price , and salvages leftovers at . Order too little and sales are lost; order too much and the surplus is dumped. The newsvendor model gives the order quantity that maximizes expected profit for a single period. Implement it for a discrete demand distribution and for normal demand. The helper normal_ppf(u), the inverse of the standard normal CDF, is provided in the starter code.
critical_fractile(price, cost, salvage=0.0)
expected_profit(q, demand_values, probs, price, cost, salvage=0.0)
optimal_order_discrete(demand_values, probs, price, cost, salvage=0.0)
demand_values is sorted ascending with probabilities probs. Return the smallest demand value whose cumulative probability is at least the critical fractile.optimal_order_normal(mu, sigma, price, cost, salvage=0.0)
expected_profit over the support; use that as a self-check.