Analysis of Consumption Patterns and Predicting Food Ingredient Needs in the Digital Era

Muhammad Rio Pratama
Gravel Product & Tech
5 min readMar 11, 2024
Photo by Pierre Bamin on Unsplash

In the marketing industry, the provision of goods is a crucial aspect in meeting consumer needs. To fulfill these needs, proper preparation regarding the quantity of goods in stock is necessary. Sometimes the existing inventory may have excessive or insufficient capacity, resulting in overstocking at suppliers which can cause issues with the turnover of capital or consumers not getting what they desire. This can affect the profits to be received by the supplier. Therefore, a prediction of demand for goods is necessary to minimize these issues as a reference for decision-making in inventory management.

One example of prediction that can be made is to predict rice stock, if you are a rice supplier so that what you provide can meet the market demand. Before making predictions, you can prepare data on rice demand for the past 12 months to generate more accurate predictions.

One way to make such predictions is through Monte Carlo Simulation. Monte Carlo is a computational technique that involves repeated random sampling to generate a prediction that can be used for decision-making. The Monte Carlo process is divided into 5 (five) stages, which include:

Establishing Probability Distribution

Probability distribution is a method used to express the likelihood of various events occurring in an experiment or event. This probability distribution provides an overview of how likely various possible values are to occur in the context of the observed random variable.

The formula for probability distribution is as follows:

Pb(i) = fq/n

Where:

Pb(i) = probability distribution

fq = frequency

n = total frequency

For example, a supplier will calculate the demand for rice from the following data over 12 months:

Thus, the calculation is as follows:

Pb(i) = 1/12, 1/12, …, 1/12

= 0.08, 0.08, …, 0.08

Then it can be presented in the following table:

Creating Cumulative Probability Distribution

Cumulative probability distribution is a function that gives the probability that a random variable will have a value less than or equal to a specific value. It is a way to accumulate probabilities from the lowest values up to the specified value, providing an overview of how likely various events or values can occur in the probability distribution.

The formula for cumulative probability distribution is as follows:

Pb(i) c = Di + Pi

Where:

Di = probability distribution

Pi = probability number

Thus, the calculation is as follows:

Pb(i) c = 0.08 + 0.08

= 0.16

Then it can be presented in the following table:

Determining Random Number Intervals

Random number intervals are the range of values obtained from a random variable in an experiment or event. In statistics, when measuring random variables, their values are often not fixed but lie within a range or interval.

The determination of random number intervals is based on the calculation of cumulative probability distribution for each month of events. The condition is that the value of x lies within the interval −∞ ≤ x ≤ ∞, where x is a continuous variable.

Then it can be presented in the following table:

Generating Random Numbers

Generating random numbers involves creating a series of numerical values without a visible pattern or directly predictable sequence. These values are produced through a process or algorithm that is inherently random, ensuring that each generated number has an equal chance of occurring. The purpose is to produce a sequence of numbers, allowing for the distribution to be obtained from the calculated results.

The formula for generating random numbers is as follows:

Xn = (a*(Xn-1) + b) mod m

Where:

Xn = random number at nth iteration

a = multiplier factor

Xn-1 = random number at (n-1)th iteration

b = increment

mod = modulus

m = divisor modulus

In this section, the Linear Congruential Generator (LCG) method can be utilized. Therefore, given the values a = 4, b = 7, m = 99, and X0 = 11.

Then, the calculation is as follows:

Xn = ((4 * 11 + 7) mod 99), ((4 * 51 + 7) mod 99), …, ((4 * 40 + 7) mod 99)

Subsequently, it can be presented in the following table:

Simulating the Experiment

Simulating the experiment involves replicating a situation whose outcomes are already known from points 1–4 above. This process includes calculating the Mean Absolute Percentage Error (MAPE). MAPE is a measurement of relative error resulting from the average absolute error calculation over a specific event month, then multiplied by 100%, resulting in a percentage. The formula for calculating MAPE is:

Where:

n = sample size

Ai = actual data value

Fi = predicted value

Then, it can be presented in the following table:

Then, the calculation is as follows:

Subsequently, it can be presented in the following table:

In the table above, the average MAPE value can be calculated as 9.56% and the accuracy is 90.44%. Thus, this accuracy qualifies as a “Very Good” prediction value.

Furthermore, based on the predictions above, it can be determined that the supplier can provide goods or rice up to 250 kg, considering the accuracy reached 100%.

Conclusion

In summary, the process of simulating the experiment involved generating random numbers based on known distributions and using them to predict demand for rice over 12 months. The Mean Absolute Percentage Error (MAPE) was calculated to measure the accuracy of the predictions, resulting in an average MAPE of 9.56% and an accuracy of 90.44%, indicating a “Very Good” prediction quality. Based on these predictions, it can be inferred that the supplier can reliably provide 250 kg of rice, especially considering the high accuracy rate of 100% for this particular prediction. This demonstrates the effectiveness of the simulation process in aiding decision-making and optimizing inventory management in the marketing industry.

--

--