public static IIntrinsicAddInterpolator <T> WithFixedNumberOfPointsOnGlobalInventoryRange <T>(
            [NotNull] this IIntrinsicAddInventoryGridCalculation <T> intrinsicAddSpacing, int numGridPointsOverGlobalInventoryRange)
            where T : ITimePeriod <T>
        {
            if (intrinsicAddSpacing == null)
            {
                throw new ArgumentNullException(nameof(intrinsicAddSpacing));
            }
            if (numGridPointsOverGlobalInventoryRange < 3)
            {
                throw new ArgumentException($"Parameter {nameof(numGridPointsOverGlobalInventoryRange)} value must be at least 3.", nameof(numGridPointsOverGlobalInventoryRange));
            }

            IDoubleStateSpaceGridCalc GridCalcFactory(ICmdtyStorage <T> storage)
            {
                T[] storagePeriods = storage.StartPeriod.EnumerateTo(storage.EndPeriod).ToArray();

                double globalMaxInventory = storagePeriods.Max(period => storage.MaxInventory(period));
                double globalMinInventory = storagePeriods.Min(period => storage.MaxInventory(period));
                double gridSpacing        = (globalMaxInventory - globalMinInventory) /
                                            (numGridPointsOverGlobalInventoryRange - 1);

                return(new FixedSpacingStateSpaceGridCalc(gridSpacing));
            }

            return(intrinsicAddSpacing.WithStateSpaceGridCalculation(GridCalcFactory));
        }
        public static IIntrinsicAddInterpolator <T> WithFixedGridSpacing <T>([NotNull] this IIntrinsicAddInventoryGridCalculation <T> intrinsicAddSpacing, double gridSpacing)
            where T : ITimePeriod <T>
        {
            if (intrinsicAddSpacing == null)
            {
                throw new ArgumentNullException(nameof(intrinsicAddSpacing));
            }
            if (gridSpacing <= 0.0)
            {
                throw new ArgumentException($"Parameter {nameof(gridSpacing)} value must be positive.", nameof(gridSpacing));
            }

            return(intrinsicAddSpacing.WithStateSpaceGridCalculation(storage => new FixedSpacingStateSpaceGridCalc(gridSpacing)));
        }