Optimal Resource Allocation: With Practical Statistical Applications and Theory