Skip to main content
3-Newcomer
November 26, 2025
Solved

Solve the problem using the Monte Carlo method

  • November 26, 2025
  • 3 replies
  • 966 views

"Problem. A Poisson stream of requests arrives at a single-channel queuing system with loss. The time between the arrivals of two consecutive requests is distributed according to the law 

DD_14416900_0-1764150530574.png 

the service time of requests is random and distributed according to the law

DD_14416900_3-1764150685539.png

Find using the Monte Carlo method over a time period T=30 min: a) the number of served requests; b) the average service time of one request."

 

If possible, please provide screenshots of the solution to the problem using Mathcad so that I can understand and clarify the essence of the solution..

 

Best answer by Werner_E

I hesitated to do the OP's homework before he showed a little initiative himself.
But okay, the dance has begun, so here are my two cents. A screenshot was asked for, right? 😉

Werner_E_0-1764301562498.png

 

3 replies

12-Amethyst
November 26, 2025

Monte Carlo Simulation of a Single-Channel Lossy System (M/M/1/1)
1. Problem Statement
The flow of requests enters the system according to an exponential distribution:
• Arrival rate: λ = 0.8 1/min

• Service time is exponentially distributed: μ = 1.5 1/min

• System: single-channel, no queue (M/M/1/1)

• Simulation time: T = 30 min
If the server is busy when a request arrives, the request is lost.
—————
2. Monte Carlo Method
Random Variable Generation
• Interarrival time:
τ = − ln(U) / λ

• Service time:
s = − ln(U) / μ
where U is a uniform random variable U(0.1).
—————
3. Algorithm for Simulating a Single Trajectory
1. Set t = 0, BusyUntil = 0.

2. Generate the next arrival time:
t ← t + InterArrival().

3. If t > T, the simulation ends.

4. If the server is free (t ≥ BusyUntil):
– Generate service time s = ServiceTime().

– Set BusyUntil = t + s.

– Increment the counter of processed requests.

5. Repeat steps until time T is reached.
—————
4. Repeating the Simulation Multiple Times
The process is repeated 5000 times, collecting statistics:
• number of requests processed,
• total service time. —————
5. Final Simulation Results
Results:
• Average number of requests processed in 30 minutes:
≈ 15.86
• Average service time per request:
≈ 0.664 min
—————
6. Interpretation
Theoretically, the average number of received requests:
E[N] = λT = 0.8 × 30 = 24.
Probability that the server is free:
ρ = λ / (λ + μ) = 0.8 / 2.3 ≈ 0.348.
That is, approximately 65% ​​of requests should be processed.
The simulation yielded 15.8 out of 24 → also approximately 66%.
Average service time:
1 / μ = 1 / 1.5 = 0.666 min.
The Monte Carlo results are in complete agreement with the theory.
—————
7. Mathcad Model Structure (for transfer to .mcdx)
Generator functions:
InterArrival() := − ln( RAND() ) / λ
ServiceTime() := − ln( RAND() ) / μ
Single trajectory simulation program:
SimulateOnce() :=
(
t ← 0;
BusyUntil ← 0;
Served ← 0;
Ssum ← 0;

WHILE t < T DO
t ← t + InterArrival();
IF t ≥ T THEN BREAK; ENDIF;

IF t ≥ BusyUntil THEN
s ← ServiceTime();
BusyUntil ← t + s;
Served ← Served + 1;
Ssum ← Ssum + s;
ENDIF;
ENDWHILE;

Served, Ssum
)
Multiple runs:
N := 5000
k := 1..N
Results[k := SimulateOnce()
Results:
AvgServed := mean( Results[0, k] )
AvgServiceTime := mean( Results[1, k] ) / AvgServed
—————
This document can be used as a tutorial or transferred entirely to Mathcad.

25-Diamond I
November 26, 2025

@NickKemaev 

Is there any specific reason why you are posting an AI 'answer' here in the forum?

12-Amethyst
November 26, 2025

I was wondering if AI could do this in MathCad. I got this answer, so I decided to share it, or is this illegal?

21-Topaz II
November 27, 2025

Hi,

See enclosed file.

Screenshots are extra 🙂

 

Werner_E25-Diamond IAnswer
25-Diamond I
November 27, 2025

I hesitated to do the OP's homework before he showed a little initiative himself.
But okay, the dance has begun, so here are my two cents. A screenshot was asked for, right? 😉

Werner_E_0-1764301562498.png

 

3-Newcomer
December 3, 2025

Thanks bro for taking the time to do the assignment. I found a way to do it and already submitted the assignment, I had to write it for a long time.
I was just wondering if it was possible to do it quickly through Mathcad.

19-Tanzanite
December 1, 2025

I thought I'd have a go at this using Prime Express.  The result can be seen below.  Although the method seems quite clever, it's as clear as mud!  My mantra was always, "clear is better than clever".  Seems I'm forced to forgo that now I only have Express!

 

Alan

MCQueue.png

 

3-Newcomer
December 3, 2025

Thank you for showing me how to quickly do the task using Mathcad. It was informative.