I am trying to use Mathematica to verify simulation results with an analytic result.
The analytic results are performance measures of the M/D/1 queue, which unfortunately uses the factorial function as shown below.
The problem I am having is that as utilization gets high ($\alpha \rightarrow 1$), then everything blows up and the results become unusable and are obviously wrong.
Can someone help me use the functions below so that they can compute the things I need in Mathematica?
Here is my code:
Pn[0, \[Alpha]_] := 1 - \[Alpha];
Pn[1, \[Alpha]_] := (1 - \[Alpha]) (E^\[Alpha] - 1);
Pn[n_Integer?NonNegative, \[Alpha]_] := (1 - \[Alpha])*
Sum[E^(j*\[Alpha])*(-1)^(n -
j)*(((j*\[Alpha] + n - j)*(j*\[Alpha])^(n - j - 1))/(n -
j)!), {j, 0, n}]
maxRho = 0.998;
c = 1/(mean*100)*maxRho;
Block[{$MaxExtraPrecision = 5000},
For[i = 0, i <= 100, i++,
lam = i*c + 0.001;
Xn = 1000;
(*lambda=0.3;*)
\[Alpha] = lam;
n = (1 - \[Alpha]) Xn;
\[Lambda] = \[Alpha];
F = (1 - Pn[k, \[Lambda]]/\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(x = 1\), \(k\)]\(Pn[
x, \[Lambda]]\)\))^First[Integer[n]];
R = 1 - F;
EX = \!\(
\*UnderoverscriptBox[\(\[Sum]\), \(k = 1\), \(30\)]R\);
Print["(", lam, ",", First[First[EX]], ")"]
]
]
First::normal: Nonatomic expression expected at position 1 in First[1.39351].
(0.001,1.39351)
First::normal: Nonatomic expression expected at position 1 in First[2.01588].
(0.01098,2.01588)
General::munfl: 1.11022*10^-16^979.04 is too small to represent as a normalized machine number; precision may be lost.
First::normal: Nonatomic expression expected at position 1 in First[2.07202].
General::stop: Further output of First::normal will be suppressed during this calculation.
(0.02096,2.07202)
(0.03094,2.15184)
General::munfl: 1.11022*10^-16^959.08 is too small to represent as a normalized machine number; precision may be lost.
(0.04092,2.25282)
(0.0509,2.3669)
(0.06088,2.48577)
(0.07086,2.60208)
(0.08084,2.71029)
(0.09082,2.80709)
(0.1008,2.8914)
(0.11078,2.96398)
General::munfl: 1.11022*10^-16^879.24 is too small to represent as a normalized machine number; precision may be lost.
General::stop: Further output of General::munfl will be suppressed during this calculation.
(0.12076,3.02689)
(0.13074,3.08281)
(0.14072,3.13459)
(0.1507,3.18476)
(0.16068,3.23538)
(0.17066,3.28792)
(0.18064,3.34327)
(0.19062,3.40183)
(0.2006,3.46363)
(0.21058,3.52839)
(0.22056,3.59566)
(0.23054,3.66485)
(0.24052,3.73537)
(0.2505,3.80664)
(0.26048,3.87815)
(0.27046,3.94954)
(0.28044,4.02056)
(0.29042,4.09113)
(0.3004,4.16132)
(0.31038,4.23133)
(0.32036,4.30149)
(0.33034,4.37215)
(0.34032,4.44374)
(0.3503,4.51662)
(0.36028,4.59118)
(0.37026,4.66765)
(0.38024,4.74624)
(0.39022,4.82712)
(0.4002,4.9102)
(0.41018,4.99555)
(0.42016,5.08302)
(0.43014,5.17285)
(0.44012,5.2647)
(0.4501,5.35885)
(0.46008,5.45487)
(0.47006,5.55297)
(0.48004,5.65391)
(0.49002,5.7572)
(0.5,5.86342)
(0.50998,5.97264)
(0.51996,6.08366)
(0.52994,6.20112)
(0.53992,6.32168)
(0.5499,6.44275)
(0.55988,6.56648)
(0.56986,6.70172)
(0.57984,6.84117)
(0.58982,6.97977)
(0.5998,7.12799)
(0.60978,7.27335)
(0.61976,7.43172)
(0.62974,7.6146)
(0.63972,7.75012)
(0.6497,7.98637)
(0.65968,8.13822)
(0.66966,8.36521)
(0.67964,8.46801)
(0.68962,8.63453)
(0.6996,9.03215)
(0.70958,9.37622)
(0.71956,9.6912)
(0.72954,9.61503)
(0.73952,9.70622)
(0.7495,8.88941)
(0.75948,10.7016)
(0.76946,10.425)
(0.77944,10.7229)
(0.78942,11.7255)
(0.7994,9.18956)
(0.80938,11.3586)
(0.81936,4.34082)
(0.82934,-16224.1)
(0.83932,12.8142)
(0.8493,-234.757)
(0.85928,6.62275)
(0.86926,15.2752)
(0.87924,13.2532)
(0.88922,16.7048)
(0.8992,17.376)
(0.90918,12.8485)
(0.91916,-5.48706*10^6)
(0.92914,-579624.)
(0.93912,-117.103)
(0.9491,20.4013)
(0.95908,20.973)
(0.96906,18.0114)
(0.97904,-252.336)
(0.98902,16.2527)
(0.999,3.95909)
Here are the simulation results. These should be just a tad lower than the values obtained above...
(0.001, 1.38589716783818)
(0.01098, 1.93374314103297)
(0.02096, 2.04522385202462)
(0.03094, 2.12186645396796)
(0.04092, 2.22403849126566)
(0.0509, 2.30691299397109)
(0.06088, 2.4378943443334)
(0.07086, 2.517177035023)
(0.08084, 2.57433346612195)
(0.09082, 2.67158769982665)
(0.1008, 2.73730997183621)
(0.11078, 2.81456659676033)
(0.12076, 2.88046155754555)
(0.13074, 2.92834154807784)
(0.14072, 2.99152596657689)
(0.1507, 3.07758958278677)
(0.16068, 3.11452150883068)
(0.17066, 3.22186780211217)
(0.18064, 3.28585314018323)
(0.19062, 3.34311179028806)
(0.2006, 3.37947576048867)
(0.21058, 3.43904742811983)
(0.22056, 3.55115038582248)
(0.23054, 3.60564960241238)
(0.24052, 3.67602522287391)
(0.2505, 3.73716344456839)
(0.26048, 3.8023064739795)
(0.27046, 3.83022560528692)
(0.28044, 3.94579480981448)
(0.29042, 3.97752100875677)
(0.3004, 4.11174789714349)
(0.31038, 4.10941122204524)
(0.32036, 4.25769629491418)
(0.33034, 4.28543667053131)
(0.34032, 4.33550740258635)
(0.3503, 4.42321705517266)
(0.36028, 4.54665402485875)
(0.37026, 4.63709534155703)
(0.38024, 4.66087141744613)
(0.39022, 4.81662374476191)
(0.4002, 4.86464050588849)
(0.41018, 4.95909206371304)
(0.42016, 5.0479785077863)
(0.43014, 5.10824300657774)
(0.44012, 5.20201717430431)
(0.4501, 5.29614975368933)
(0.46008, 5.36298433627588)
(0.47006, 5.49571576491656)
(0.48004, 5.6751101667503)
(0.49002, 5.67510989318424)
(0.5, 5.82865734860674)
(0.50998, 5.87748869917215)
(0.51996, 6.06715682675748)
(0.52994, 6.20824576522561)
(0.53992, 6.32709817320504)
(0.5499, 6.43811298970349)
(0.55988, 6.54654046655082)
(0.56986, 6.68678926260718)
(0.57984, 6.80169359902264)
(0.58982, 6.9518458553012)
(0.5998, 7.18302700779921)
(0.60978, 7.26791401965148)
(0.61976, 7.46058198390404)
(0.62974, 7.6028334326128)
(0.63972, 7.73442299789392)
(0.6497, 7.95705167019446)
(0.65968, 8.10187610383737)
(0.66966, 8.2822881207868)
(0.67964, 8.51473176758009)
(0.68962, 8.80623111370376)
(0.6996, 8.99592207159753)
(0.70958, 9.05867682860675)
(0.71956, 9.39082704752084)
(0.72954, 9.71967711010753)
(0.73952, 10.0616975101211)
(0.7495, 10.3163942606361)
(0.75948, 10.4803904667259)
(0.76946, 10.9672798131673)
(0.77944, 11.1338450777013)
(0.78942, 11.6669130099429)
(0.7994, 12.1099037780777)
(0.80938, 12.3838005979187)
(0.81936, 12.9501380959976)
(0.82934, 13.5238685220341)
(0.83932, 13.7657134896756)
(0.8493, 14.3022168202217)
(0.85928, 15.146915943203)
(0.86926, 15.9529380044323)
(0.87924, 16.5836713009528)
(0.88922, 17.6962236798752)
(0.8992, 18.3914440210623)
(0.90918, 19.7524583648123)
(0.91916, 21.1159814023742)
(0.92914, 22.4887559250303)
(0.93912, 23.7662819041863)
(0.9491, 27.3198186537483)
(0.95908, 30.0755919036298)
(0.96906, 34.546908244586)
(0.97904, 40.2033189750874)
Integer
is the head for integers, it is not a function. What are you trying to do withFirst[Integer[n]]
? Are you trying toRound
the value ofn
? Find theFloor
forn
? Something else? $\endgroup$