Bayesian Inference for Dynamic Demand Forecasting and Inventory Optimization

Research Article
Open access

Bayesian Inference for Dynamic Demand Forecasting and Inventory Optimization

Ziyang Xiao 1*
  • 1 Department of Mathematics, University of Toronto, Toronto, Canada    
  • *corresponding author zoey.xiao@mail.utoronto.ca
Published on 17 April 2025 | https://doi.org/10.54254/2753-8818/2025.22036
TNS Vol.92
ISSN (Print): 2753-8818
ISSN (Online): 2753-8826
ISBN (Print): 978-1-83558-973-1
ISBN (Online): 978-1-83558-974-8

Abstract

This paper constructs a dynamic model suitable for demand forecasting and inventory optimization based on Bayesian theory. The model uses Bayesian inference to achieve real-time updates of demand data and combines cost minimization methods to control inventory. The study looks at seasonal changes and sudden market problems. It uses probability distributions to give detailed forecast results. Tests show this method works better to lower inventory costs and improve service levels. The model keeps updating demand predictions. This helps companies act fast when markets change. It also helps them manage their inventory better. The model adapts to changing demand patterns, making inventory management more flexible. It also reduces the risk of stock shortages or excess inventory. In addition, the paper discusses in detail the model design principles, data processing procedures, and actual application effects and suggests further optimizing the model. The results show that dynamic adjustment strategies can effectively cope with the uncertainty of market demand, thereby promoting the improvement of enterprise operational efficiency.

Keywords:

Bayesian inference, Demand forecasting, Inventory optimization, Dynamic updating, Uncertainty management

Xiao,Z. (2025). Bayesian Inference for Dynamic Demand Forecasting and Inventory Optimization. Theoretical and Natural Science,92,116-122.
Export citation

1. Introduction

The market today is complex and changes often. Businesses need to predict demand accurately and manage inventory well to succeed. Old methods struggle to handle demand changes and unpredictable factors. To this end, this paper explores the construction and application of a dynamic demand forecasting and inventory optimization model based on Bayesian inference.

The core ideas of this study come from multiple cutting-edge studies. Xu & Guan proposed the application of Bayesian learning in dynamic inference, which provided theoretical support for constructing a dynamic Bayesian demand forecasting model in this study [1]. Hu & Li studied the method of combining a Bayesian network with particle swarm optimization (PSO) to achieve more accurate demand forecasting [2]. This method inspired this study to adopt an adaptive optimization strategy when dynamically adjusting the prior distribution. In addition, Chen et al. used a Bayesian neural network to predict express delivery demand, emphasizing the superiority of the Bayesian method in dealing with uncertain demand, which is highly consistent with the goal of this study [3].

Loaiza-Maya reviewed Bayesian forecasting methods in the 21st century [4]. Their work highlights how Bayesian methods can model uncertainty. This study uses these ideas and adds time series dynamics to build a Bayesian hierarchical model for retail demand forecasting. Yang et al. created a Bayesian deep learning method [5]. So, the forecasting model takes into account both computational efficiency and forecasting accuracy. Lavine, Cron, & West studied the application of Bayesian computing in dynamic latent factor models, providing theoretical support for the computational framework of this study [6].

In terms of inventory management, Bayesian methods have been applied to fields such as public health, smart grids, and small-area forecasting [7,8]. Wang et al. studied the application of Bayesian methods in food safety data monitoring and demonstrated its reliability in a highly dynamic environment [7]. This paper draws on their ideas and constructs an inventory optimization framework based on Bayesian updates to adapt to demand fluctuations. Bauer et al. studied the small-area forecasting of opioid-related mortality and used the Bayesian spatiotemporal dynamic modeling method to provide a reference for the dynamic adjustment of inventory decisions in this study [8].

The main idea of this study is to use Bayesian inference, demand forecasting, and inventory optimization together. This helps create an inventory management system that updates over time. Traditional methods like SARIMA, ETS, and Prophet only give point forecasts. The Bayesian method does more. It also measures forecast uncertainty. This provides better information and helps make better inventory decisions. Experimental results show that this method has higher forecast accuracy and adaptability during holidays, high demand fluctuations, and abnormal market events (such as promotions and weather changes).

2. Method and Theory

Bayes’ theorem is a basic tool of probability theory, which is a systematic way of parameter estimation and decision-making in environments with uncertainties [9]. This section forms a groundwork of a methodological basis by extending the classical probability and mathematical statistics theory. Bayes’ theorem is shown at the core of a probabilistic demand modeling and its synergistic integration with inventory optimization models for dynamic demand uncertainty. A theoretical framework with strict mathematical expression is constructed by means of systematic analysis.

The above subsections outline the two dimensions of probabilistic modeling and operation decision optimization of demand forecasting. International standards of mathematical notation are used: normal distributions, namely, Ν \( (μ,{σ^{2}}) \) . and expectation operators, \( Ε[Χ] \) , in order to achieve methodological consistency through the whole research workflow.

2.1. Bayesian Theorem and Probabilistic Foundations

The main tool for using Bayes’ theorem in probability theory is to update beliefs given new evidence. Its classic expression is:

\( Ρ(Α|Β)=\frac{Ρ(Β|Α)\cdot Ρ(Α)}{Ρ(Β)}\ \ \ (1) \)

The idea of conditional probability is explained in this formula, because the belief in event Α changes after new information B is acquired. The Bayesian theorem has special significance in inventory management since it allows researchers to reevaluate future demand prediction using observed demand data continuously.

Bayesian inference is different from traditional statistics regarding how uncertainty is addressed. Parameters are treated as random variables in conventional frequency statistics, the distribution of which is defined by a probability. The Bayesian framework integrates classical statistical principles such as the Law of Large Numbers (LLN) and the Central Limit Theorem (CLT) to create a more exhaustive probability model. It is especially helpful when one would like to model uncertainty in dynamic environments.

In selecting a prior distribution, one should take into account at least the complexity of the model and perhaps also the quantity of data available. The normal distribution Ν \( (μ,{σ^{2}}) \) or uniform distribution is used for demand forecasting [9]. Very importantly, the choice of the prior distribution affects the posterior distribution, particularly in an early stage when the amount of data is small [10]. As data accumulates, the posterior distribution will gradually converge, and the influence of the prior will gradually weaken. To predict product demand, the normal distribution can be used as a prior. Its conjugate prior property helps simplify calculations.

A normal distribution can be used as the prior when predicting commodity demand. Its conjugate prior property simplifies calculations. When new sales data arrive, Bayesian updating adjusts the posterior distribution parameters directly. This process avoids complex numerical integration. However, a single normal prior may cause prediction bias if actual demand has multiple peaks. In that case, a mixture distribution or a non-parametric method may be more suitable.

For dynamically changing requirements, the Bayesian update process can be expressed as:

\( Ρ(Demand|Data)=\frac{Ρ(Data|Demand)\cdot Ρ(Demand)}{Ρ(Data)}\ \ \ (2) \)

Here, \( Ρ(Demand) \) is the prior distribution of demand, \( Ρ(Data|Demand) \) is the likelihood of observing the data given a demand level, and \( Ρ(Demand|Data) \) is the posterior distribution after updating with new data. This approach leverages LLN and CLT by assuming that demand sample means are normally distributed for large datasets, facilitating probabilistic modeling of uncertainty in dynamic environments. In the real-world scenario, if people think that the demand follows a normal distribution, one can directly calculate the mean and variance of the posterior distribution. The benefit of this approach is that it provides not only a point estimate, but also a measure of forecast uncertainty, providing more detailed information for inventory selection.

The innovation of this study is the analysis of the impact of changing requirements on Bayesian updating. These needs include seasonal changes and emergencies. Specifically, the study explores how time series instability affects the choice of prior distributions. This paper proposes a dynamic adjustment method for the demand that has a significant changing trend. To let the prior distribution automatically follow the changes in the demand, people can use the method. This paper designs a hierarchical Bayesian model for demand with seasonal changes. The key parameter used to improve the forecasting accuracy of the model is the seasonal effect. The Bayesian update method based on abnormal conditions is developed to handle a sudden change in demand due to events such as promotions or anomalous weather. This method can find outliers in the data and handle the weight of the likelihood function [9]. This can keep its short-term value but reduces the long-term impact of the anomaly data. It places this method to greatly improve the ability of the model to deal with unstable cases.

The core formula for Bayesian parameter estimation is as follows:

\( Ρ(μ|{x_{1}},⋯,{x_{n}})∝Ρ({x_{1}},⋯,{x_{n}}|μ)\cdot Ρ(μ)\ \ \ (3) \)

The prior distribution is denoted as Ρ(μ) (which stands for distribution of the parameter μ of the initial cognition). \( Ρ({x_{1}},⋯,{x_{n}}|μ) \) is the likelihood function, the probability of observing the data \( \lbrace {x_{1}},⋯,{x_{n}}\rbrace \) given a specific value of \( μ \) . It is a way to quantify how well the observed data explains the parameter μ. Nonetheless, since the accuracy of demand forecasts drives forward decision-making, this approach allows people to continuously optimize the learning process to enhance the accuracy of demand forecasts.

2.2. Inventory Optimization Model Design

This section merges Bayesian theorem and probability foundations in order to develop an inventory optimization model under dynamic demand uncertainty. The model aims at balancing inventory holding costs, ordering costs and stock-out costs while achieving an established service level (e.g., 95%) and the integration of seasonal demand and change, as well as rare and undesired demand or new technology changes.

The first is the demand forecasting integration. This model uses Bayesian inference and introduces posterior demand distribution:

\( Ρ(Demand|Data)∝Ρ(Data|Demand)\cdot Ρ(Demand)\ \ \ (4) \)

where \( Ρ(Demand) \) is the prior distribution such as normal distribution \( Ν(μ,{σ^{2}}) \) , and \( Ρ(Data|Demand) \) is the likelihood function. According to LLN and CLT, under the assumption of independent and identical distribution (i.i.d.), the sample demand mean is close to a normal distribution. The reorder point R is determined by:

\( R=Ε[Demand|Data]+z\cdot {σ_{Demand|Data}}\ \ \ (5) \)

where \( z \) is the safety factor for the target service level, like \( z=1.65 \) for 95%.

In the cost minimization framework, the model optimizes total cost:

\( C=h\cdot Ε[Inventory Level]+o\cdot Ε[Order Frequency]+s\cdot Ρ(Stockout)\ \ \ (6) \)

where h is holding cost, o is ordering cost, and s is stockout cost. The dynamic Bayesian update mechanism ensures that cost estimates can be adjusted in real time as demand changes.

The Hierarchical Bayesian Model and the parameter \( {S_{t}} are \) introduced to handle the seasonal demand and optimize under dynamic demand. The requirements are modeled as follows:

\( {D_{t}}=μ+{S_{t}}+{ϵ_{t}}, { ϵ_{t}} ~ Ν(0,{σ^{2}})\ \ \ (7) \)

Here, \( {S_{t}} \) is historical data updates to keep inventory for seasonal patterns. Further, the model also optimizes the predictions in terms of likelihood weight becoming adjusted for sudden changes (like weather changes and promotions):

\( Ρ(Data|Demand, Anomaly)=w\cdot Ρ(Data|Demand)+(1-w)\cdot Ρ(Anomaly)\ \ \ (8) \)

They maintain short-term responsiveness where w is dynamically updated to minimize long-term bias [9]. It combines Bayesian demand forecasting with dynamic decision-making for dealing with non ­ stationary demand.

3. Results and Application

3.1. Data Description and Preprocessing

The purpose of the application of Bayesian demand forecasting and inventory optimization models is introduced in this section. Retail sales data from the “Store Item Demand Forecasting Challenge” in Kaggle are used for testing the model [11]. Results are shown for adapting the model to changing demands and inventory management. The dataset from Kaggle consists of 50 products sales over 10 stores over the years from 2013 – 2018 [11]. The dataset contains about 913,000 records. The dataset exhibits several key characteristics: Strong seasonal patterns, including annual, monthly, and weekly cycles, and various trends across product categories.

The first step is to preprocess the data before applying the model. The researchers aggregated daily sales data into weekly data to reduce noise and preserve seasonal characteristics. The researchers detected and marked outliers that exceeded three standard deviations from the mean. They filled missing values with the mean of the adjacent weekly data, as missing values were less than 1%. The data was divided into the first four years for training and the last year for testing. Three representative products are selected: item 1 in store 1 (high sales, obvious seasonality), item 27 in store 5 (medium sales, medium trend), and item 43 in store 8 (low sales, high variability).

The Bayesian forecasting model was applied using normal distribution priors. The priors were based on the first 12 weeks of data. Item 1: \( Ν(45.2, 64) \) , an average demand of 45.2 units with standard deviation of 8 units. Item 27: \( Ν(22.8, 36) \) , an average demand of 22.8 units with standard deviation of 6 units. Item 43: \( Ν(11.5, 16) \) , an average demand of 11.5 units with standard deviation of 4 units.

The model updates the demand estimates weekly using the Bayesian Eq. (4). To account for seasonal effects, using a hierarchical Bayesian model [see Eq. (7)]. \( {S_{t}} \) optimizes inventory for seasonal patterns, which updates based on historical data. Anomaly detection methods are also applied. If the demand changes by more than 2.5 standard deviations, the model adjusts the weights of the likelihood function. This enables the model to respond quickly to changes without being misled by short-term anomalies.

3.2. Forecasting Performance Results

By comparing the Bayesian model against three traditional forecasting methods popular in retail. The first is seasonal ARIMA (SARIMA), the second is exponential Smoothing with seasonality (ETS), and the third is time series forecasting model developed by Facebook (Prophet).

Performance was evaluated by using Mean Absolute Percentage Error (MAPE), Root Mean Square Error (RMSE) and Mean Absolute Error (MAE) on the test dataset, see Table 1 and Table 2 for Item 1 and Item 27, respectively.

Table 1: Results for Item 1 (high sales, obvious seasonality)

Method

MAPE

RMSE

MAE

Bayesian

8.4%

7.21

5.83

SARIMA

10.1%

8.56

6.92

ETS

9.7%

8.12

6.64

Prophet

9.2%

7.95

6.41

Table 2: Results for Item 27 (medium sales, medium trend)

Method

MAPE

RMSE

MAE

Bayesian

12.3%

4.65

3.52

SARIMA

13.8%

5.21

4.07

ETS

13.1%

4.98

3.85

Prophet

12.7%

4.83

3.68

From these two Tables, it is definite that the Bayesian model performed better than all other methods on every metric. It showed especially strong results in the following cases:

During holiday periods, where it reduced MAPE by 17.5% compared to the next best method.

During promotions, where its anomaly adjustment kept forecast errors at 14.2% on average, compared to 21.6% for SARIMA.

After significant demand shifts, where its continuous updates helped it adapt 22% faster.

One key advantage of the Bayesian model was that it provided full probability distributions instead of just point forecasts. This made it possible to measure uncertainty in predictions.

3.3. Inventory Optimization Application

The inventory optimization model applies Bayesian demand forecasting. The goal is to minimize total costs while maintaining a 95% service level. The reorder points were calculated using formula Eq. (5), where \( z \) =1.65 corresponds to the 95% confidence level. Cost parameters are based on industry averages: holding costs(h) are $1.8 per unit per week, ordering costs(o) are $45 per order, and stockout costs(s) are $12 per unit. The total cost function was Eq. (6).

Over a one-year testing period, simulation results showed significant improvements: total inventory costs were reduced by 14.2 percent, service levels increased from 92.1 percent to 95.7 percent, average inventory levels decreased by 9.6 percent, and out-of-stock events were reduced by 41.3 percent, compared to the company’s previous fixed reorder point policy. The most significant improvement occurred for item 43(low sales, high variability). Out-of-stocks decreased by 53%, while inventory levels remained stable.

3.4. Practical Implications

This research shows the key benefits of using Bayesian methods for managing inventory. First, the model can keep updating itself whenever new data comes in. This helps keep the forecasts accurate. Second, the Bayesian approach can spot and fix unusual changes in demand. This prevents long-term mistakes. Also, the model gives a way to measure uncertainty. That helps managers make better decisions about inventory using this probability pattern. Finally, the model can automatically pick up weekly and yearly seasonal changes. No manual adjustment is needed, and the forecasts are more flexible.

Although the Bayesian model performs well in inventory optimization, it still has some limitations. For products with highly unstable demand, the typical prior may not accurately describe the data distribution, so hybrid models or non-parametric methods can be considered to improve forecasts in the future. For new products with less historical data, the model relies on prior information set by experts when there is insufficient data support, which may affect the forecast effect. Future research can explore more automated prior setting methods to improve the applicability of the model in different business scenarios.

4. Conclusion

This paper constructs a dynamic demand forecasting and inventory optimization model. The model updates real-time demand data through Bayesian inference. At the same time, the cost minimization framework is used to reasonably regulate inventory. The study fully considers seasonal fluctuations and sudden abnormal situations and uses probability distribution to provide more comprehensive forecast information. The experimental results show that this method has substantial advantages in reducing inventory costs, improving service levels, and quickly responding to market anomalies. This essay mentions the advantages and disadvantages of the model design and proposes hybrid models and non-parametric methods as future improvement directions. It also recommends further exploration of data preprocessing and automatic adjustment mechanisms for model parameters. The research provides a scientific basis for enterprises to manage inventory in an uncertain environment and points out the direction for subsequent study in related fields. The model generally has high practical value and application prospects and can provide strong support for enterprises to improve operational efficiency and optimize decision-making processes. At the same time, it also lays a solid foundation for further theoretical research and practical improvement.


References

[1]. Xu, A., & Guan, P. (2022). Bayesian learning for dynamic inference. arXiv:2301.00032v1.

[2]. Hu, S., & Li, K. (2023). Bayesian Network Demand-Forecasting Model based on modified particle swarm optimization. In Seung-Hoon Yoo (Ed.), Appl. Sci., 13, 10088).

[3]. Chen, R., 1, Zhong, X., Xu, X., Department of Economic Management, Hulunbuir University, & Department of Engineering, Hulunbuir University. (2023). Bayesian Neural Network-Based Demand Forecasting for express transportation. In Highlights in Science, Engineering and Technology ISET 2023 (Vol. 68, pp. 259–260).

[4]. Rubén Loaiza-Maya. (2022). Bayesian Forecasting in the 21st Century: A Modern Review. International Journal of Forecasting, 40(2), 811-839.

[5]. Yang, Y., Li, W., Gulliver, T. A., & Li, S. (2019). Bayesian Deep Learning-Based Probabilistic Load Forecasting in smart grids. IEEE Transactions on Industrial Informatics, 16(7), 4703–4713.

[6]. Lavine, I., Cron, A., & West, M. (2022). Bayesian computation in dynamic latent factor models. Journal of Computational and Graphical Statistics, 31(3), 651–665.

[7]. Wang, X., Zhou, M., Jia, J., Geng, Z., & Xiao, G. (2018). A Bayesian Approach to Real-Time Monitoring and Forecasting of Chinese foodborne diseases. International Journal of Environmental Research and Public Health, 15(8), 1740.

[8]. Bauer, C., Zhang, K., Li, W., Bernson, D., Dammann, O., LaRochelle, M. R., & Stopka, T. J. (2023). Small area Forecasting of Opioid-Related Mortality: Bayesian Spatiotemporal Dynamic Modeling Approach. JMIR Public Health and Surveillance, 9, e41450.

[9]. Vehtari, A., Dunson, D. B., Carlin, J. B., Stern, H. S., Rubin, D. B., & Gelman, A. (2013). Part II: Fundamentals of Bayesian Data Analysis. In Bayesian Data Analysis. CRC Press LLC.

[10]. Udomvisawakul, A. (2021). Applying Bayesian Growth Modeling in Machine Learning for Longitudinal Data. ProQuest Dissertations & Theses.

[11]. Store item Demand Forecasting challenge. (n.d.). Kaggle. https://www.kaggle.com/competitions/demand-forecasting-kernels-only/data.


Cite this article

Xiao,Z. (2025). Bayesian Inference for Dynamic Demand Forecasting and Inventory Optimization. Theoretical and Natural Science,92,116-122.

Data availability

The datasets used and/or analyzed during the current study will be available from the authors upon reasonable request.

Disclaimer/Publisher's Note

The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of EWA Publishing and/or the editor(s). EWA Publishing and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

About volume

Volume title: Proceedings of the 3rd International Conference on Mathematical Physics and Computational Simulation

ISBN:978-1-83558-973-1(Print) / 978-1-83558-974-8(Online)
Editor:Marwan Omar
Conference website: https://2025.confmpcs.org/
Conference date: 27 June 2025
Series: Theoretical and Natural Science
Volume number: Vol.92
ISSN:2753-8818(Print) / 2753-8826(Online)

© 2024 by the author(s). Licensee EWA Publishing, Oxford, UK. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license. Authors who publish this series agree to the following terms:
1. Authors retain copyright and grant the series right of first publication with the work simultaneously licensed under a Creative Commons Attribution License that allows others to share the work with an acknowledgment of the work's authorship and initial publication in this series.
2. Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the series's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgment of its initial publication in this series.
3. Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See Open access policy for details).

References

[1]. Xu, A., & Guan, P. (2022). Bayesian learning for dynamic inference. arXiv:2301.00032v1.

[2]. Hu, S., & Li, K. (2023). Bayesian Network Demand-Forecasting Model based on modified particle swarm optimization. In Seung-Hoon Yoo (Ed.), Appl. Sci., 13, 10088).

[3]. Chen, R., 1, Zhong, X., Xu, X., Department of Economic Management, Hulunbuir University, & Department of Engineering, Hulunbuir University. (2023). Bayesian Neural Network-Based Demand Forecasting for express transportation. In Highlights in Science, Engineering and Technology ISET 2023 (Vol. 68, pp. 259–260).

[4]. Rubén Loaiza-Maya. (2022). Bayesian Forecasting in the 21st Century: A Modern Review. International Journal of Forecasting, 40(2), 811-839.

[5]. Yang, Y., Li, W., Gulliver, T. A., & Li, S. (2019). Bayesian Deep Learning-Based Probabilistic Load Forecasting in smart grids. IEEE Transactions on Industrial Informatics, 16(7), 4703–4713.

[6]. Lavine, I., Cron, A., & West, M. (2022). Bayesian computation in dynamic latent factor models. Journal of Computational and Graphical Statistics, 31(3), 651–665.

[7]. Wang, X., Zhou, M., Jia, J., Geng, Z., & Xiao, G. (2018). A Bayesian Approach to Real-Time Monitoring and Forecasting of Chinese foodborne diseases. International Journal of Environmental Research and Public Health, 15(8), 1740.

[8]. Bauer, C., Zhang, K., Li, W., Bernson, D., Dammann, O., LaRochelle, M. R., & Stopka, T. J. (2023). Small area Forecasting of Opioid-Related Mortality: Bayesian Spatiotemporal Dynamic Modeling Approach. JMIR Public Health and Surveillance, 9, e41450.

[9]. Vehtari, A., Dunson, D. B., Carlin, J. B., Stern, H. S., Rubin, D. B., & Gelman, A. (2013). Part II: Fundamentals of Bayesian Data Analysis. In Bayesian Data Analysis. CRC Press LLC.

[10]. Udomvisawakul, A. (2021). Applying Bayesian Growth Modeling in Machine Learning for Longitudinal Data. ProQuest Dissertations & Theses.

[11]. Store item Demand Forecasting challenge. (n.d.). Kaggle. https://www.kaggle.com/competitions/demand-forecasting-kernels-only/data.