Home > Mobile >  Beta distribution curves with Python and scipy to distribute man-days effort
Beta distribution curves with Python and scipy to distribute man-days effort

Time:05-06

The goal is to distribute man-days effort (y axis) through the days time period (x axis) according to defined curve shapes: Bell, FrontLoad, BackLoad, U-shape

These models could be perfectly drawn with Density result graphs:

CodePudding user response:

The instantaneous value of the pdf isn't bounded on [0,1]. Only the integral over any subset is. In this case, you want your subsets to be days, so you'd need to integrate over each day. That's not easy with the pdf, but with the pre-integrated cdf, it's easy - just take the running difference:

y1 = np.diff(beta.cdf(x, 2, 8))  # a=2, b=8. FrontLoad distribution
y2 = np.diff(beta.cdf(x, 5, 5))  # a=5, b=5. Bell-shape distribution
y3 = np.diff(beta.cdf(x, 8, 2))  # a=8, b=2. BackLoad distribution

I can't attach images, but that should give you your expected graphs.

Also this:

y1_demands = [total_demand*y for y in y1]

can just be:

y1_demands = total_demand*y1

numpy is intended to prevent for loops, that are slow in python. if you find yourself iterating through arrays, there's probably a much faster (and usually clearer) way to do it in numpy.

  • Related