Sort by

recency

|

8 Discussions

|

  • + 0 comments

    74+11(47-X)<20 X>51.91 Then apply P(X>51.91) on a normal distribution of N(50,10/sqrt(11)), and you'll get 0.2632

  • + 0 comments

    If we start with 74,000 gallons and need to have at least 20,000 gallons after 11 weeks, then we cannot afford to lose more than (74,000 - 20,000)/11 each week.

    We also know that if we sell on average 50,000 gallons each week and add a constant 47,000 gallons each week, then on average we can expect to lose 3,000 gallons each week.

    Now knowing that on average we will lose 3,000 gallons each week, what is the probability we will lose more than (74,000-20,000)/11 each week?

  • + 0 comments
    import math
    def cdf(x, mu, sigma):
        return 0.5 + math.erf((x-mu)/(sigma*2**0.5))*0.5
    
    mu = 50000
    sigma = 10000
    
    weeks=11
    start = 74000
    weekly = 47000
    end = start + weekly*weeks
    lower_bound = end - 20000
    
    sum_mu = weeks*mu
    sum_sigma = weeks**0.5*sigma
    
    print('{:0.4f}'.format(1-cdf(lower_bound, sum_mu, sum_sigma)))
    
  • + 0 comments

    The distribution of the remaining supply is really not normal anymore and is only positive since you clearly cant have a negative balance. My approach is to explicitly simulate the weekly remainder but having a check for less than 0 remainder, in which case, I force it to take the weekly delivered amount as the left over amount for that week.

    remainder = 0
    num_exp=100000
    delivery = 47
    res = []
    for exp in range(1,num_exp):
        start = 74
        remainder = start
        for week in range(1,12):
            remainder = remainder - np.random.normal(50, 10)
            if (remainder <=0):
                remainder = delivery
            else:
                remainder += delivery
        res.append(remainder)
    
  • + 1 comment

    I'm stucked at the following challenge #6 because this one's implementation is wrong, as anything > 0.1999 will pass.

    Can someone look at my implementation and tell me where I'm failing?

    from math import sqrt
    from scipy.stats import norm
    
    init_supply = 74000
    mu = 50000.
    sigma = 10000
    weeks = 11
    delivery = 47000
    sample_mu = 20000.
    
    mu_11w = init_supply + (delivery-mu)*weeks
    sigma_11w = sigma * weeks
    
    diff_mu = sample_mu - mu_11w
    z = diff_mu / sigma_11w
    print(format(norm.cdf(z), '.4f'))
    

    Below the calculations to support the choice of my equations (init_supply → supply, delivery → X, weeks → w)

    mu_11w = supply + (X-mu)*w
    
    sigma_11w = (supply + (X-mu+sigma)*w) - (supply + (X-mu)*w)
              = supply + X*w - mu*w + sigma*w - supply - X*w + mu*w
              = sigma*w
    
    diff_mu =  sample_mu - mu_11w
    
    z = diff_mu * sqrt(N) / sigma_11w
    N=1 ⇒ z = diff_mu / sigma_11w