Write a function to calculate the optimal inventory levels based on historical sales data for a retail use case.