{VERSION 4 0 "IBM INTEL LINUX22" "4.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 1 12 0 0 255 1 0 2 0 0 1 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 16 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Hea ding 1" -1 3 1 {CSTYLE "" -1 -1 "Times" 1 14 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 6 6 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 2" -1 4 1 {CSTYLE " " -1 -1 "Times" 1 14 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 4 4 1 0 1 0 2 2 0 1 }{PSTYLE "R3 Font 0" -1 256 1 {CSTYLE "" -1 -1 "Courier" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "R3 \+ Font 2" -1 257 1 {CSTYLE "" -1 -1 "Times" 1 12 128 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 258 1 {CSTYLE "" -1 -1 "Times" 1 16 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Title" -1 259 1 {CSTYLE "" -1 -1 "Times" 1 24 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }3 1 0 0 12 12 3 0 3 0 2 2 19 1 } {PSTYLE "Maple Output" -1 260 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 3 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Title" -1 261 1 {CSTYLE "" -1 -1 "Times" 1 36 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }3 1 0 0 12 12 3 0 3 0 2 2 19 1 }{PSTYLE "Normal" -1 262 1 {CSTYLE "" -1 -1 "Times" 1 18 255 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 527 "restart: if kernelo pts(platform)=\"unix\" \n then unix:= true; win98:= false; \n date_str ing:= convert(substring(ssystem(\"date \"\"+%a %d/%m/%Y\"\" \")[2], 1. .-2), symbol)\n else unix:= false; win98:= evalb(ssystem(\"win\")[2][1 ..13]=\"Vous utilisez\"); \n if win98 then tmp:= ssystem(\"date\")[2] ; searchtext(\":\", tmp); \n tmp:= cat(substring(tmp, 1..%-2), \" \+ \", substring(tmp, %+1..-1));\n date_string:= substring(tmp, 22..3 5);\n else date_string:= ssystem(\"date /t\")[2][1..-2];\n fi: fi: 'u nix'=unix, 'win98'=win98, 'date'= date_string;" }}}{EXCHG {PARA 262 " " 0 "" {TEXT -1 56 "sous win98, taper [entr\351e] pour sortir de la fe netre DOS" }}{PAGEBK }{PARA 262 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 261 "" 0 "" {TEXT -1 14 "Simul (v68-21)" }}}{EXCHG {PARA 258 "" 0 "" {TEXT -1 64 "Copyright (c) 1999-2007 Pierre L. Douillet \n" }}{PARA 258 "" 0 "" {TEXT -1 11 "Licence GPL" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 258 "" 0 "" {TEXT -1 194 "libre reproductio n pour un usage universitaire sous reserve d'une copie compl\350te,\na vec reproduction du programme source dont, en particulier, la pr\351se nte mention\n \naucune garantie de fiabilit\351. " }}{PARA 258 "" 0 " " {TEXT -1 89 "en particulier, toute utilisation dans un contexte indu striel est vivement d\351conseill\351e\n " }}}{EXCHG {PARA 262 "" 0 " " {TEXT -1 38 "chargement par la commande with(simul)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 15 "Initialisations" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "gc ( ); kernelopts(ASSERT=true):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 465 "[libname][-1]; racine:= %[1..-4]:\ndo loc:= searchtext(\"\\\\ \",racine); if loc = 0 then break fi;\nracine:= cat(substring(racine,1 ..loc-1),\"/\", substring(racine,loc+1..-1)); od:\ndo loc:= searchtext (\"\\\\\",racine); if loc = 0 then break fi;\nracine:= cat(substring(r acine,1..loc-1),\"/\", substring(racine,loc+1..-1)); od:\nloc:= Search Text(\"MAPLE\", racine): if loc <> 0 then\nracine:= cat(substring(raci ne,1..loc-1),\"Maple\", substring(racine,loc+5..-1)); fi: \n'racine'=r acine; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 69 "kernelopts(versi on): Version:= substring(%, 1..searchtext(\",\", %)-1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 77 "Test if \"pldx\" is preloaded, as require d for this library to operate properly" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 206 "try read( cat(racine, \"update/check.m\"));\nprint(`The usual 'update' directory stil exists, as requiered`);\ncatch: print (` An ' update' repertory MUST be created, using 'pldx' package`);;\nend try; \+ print(``);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 27 "Biblioth\350que compl\351mentaire" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "unprotect(savelib); savelib:= proc( ) error \"savelib is gone\" end :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "ssavelib:= NULL:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 1063 "xsavelib:= proc() local filename, values, library, pathname, f; \nglobal ssavelib, libname; option `Copyright Pld`;\nif assigned(libna me) then library := op(1, eval([libname], 1))\n else error \"the globa l variable `libname' must be assigned\"\nend if;\nif nargs < 2 then er ror \"no names specified to save\" end if;\nfilename := args[nargs];\n values := args[1 .. nargs - 1] ;\nif not type(filename, '\{string, sym bol\}') \n then error \"last argument (filename) must be a string\" \+ end if;\nif not searchtext(\".m\", filename, -2 .. -1) = 1 \n then er ror \"last argument (filename) must be a *.m string\" end if;\n if not type([values], 'list(\{symbol, string\})') \n then f := remove(type , [values], \{symbol,string\}); \n error \"all arguments must be symb ols, cannot save these %1\", f\n end if;\n pathname := cat(library, \+ \"/\", filename);\n f := subs('T' = ( (op@map)(convert, [values], sym bol), pathname), \n proc() save T end proc);\n try f(); ssavelib:= ssavelib, values; return; \n catch: print(lasterror); \n end try ;\nerror \"unable to save %1 in %2\", [values], library\nend proc:" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "tzx:=\"\": xsavelib('tzx', \+ `simul.m`); xsavelib('tzx', `simul6.m`); " }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 36 "ssavelib:= NULL: ever_load:= NULL :" }}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 4 "init" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 427 "\"simul v68-21 ; author : ; last mod if (v68) : \"\n || (date_string):\n`simul/init`:= \n subs(message=%, \+ proc() option `Copyright Pierre L. Douillet`;\n global `stats/transfo rm/functions/tally`, _seed;\n stats['transform', 'tally'](['red', 'bl ue', 'red']):\n `stats/transform/functions/tally`:= eval(`simul/tally `):\n if not assigned(_seed) then _seed:=1; fi; \n print(convert(me ssage, symbol)) end): %();" }}}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 7 "Xmacros" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 202 "xmacro:= proc ();\nmacro(\n'moy'=stats[' describe','mean'],\n'var'=stats['describe','variance'],\n'cov'=stats[' describe','covariance'],\n'xab'=stats['describe','range'],\n'nbr'=stat s['describe','count']);\nend:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "ev er_load:= ever_load, xmacro:" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 66 "Good generators are har d to find : LGM (xlgm_ini, xlgm, xpie2proc)" }}{SECT 0 {PARA 4 "" 0 " " {TEXT -1 4 "xlgm" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 132 "`xlgm _ini` := proc(seed::integer) option `Copyright LGM`; global lgm_s;\n \+ if nargs = 0 then lgm_s := 1 else lgm_s := seed fi\nend ;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 124 "xlgm:= proc() option `Copyr ight LGM`;\n global lgm_s; lgm_s := irem(lgm_s*16807, 2147483647); ev alhf(lgm_s/2147483647) end ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 96 "ra:= proc() global _seed;\n_seed := irem(427419669081*_seed, 999 999999989); Float(_seed,-12)\nend;" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 30 "xpie2proc : bien plus rapide !" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 433 "xpie2proc:= proc(fun) option `Copyright Pierre L. D ouillet`; local x, action; x := 'x': \naction:= proc(x, fu) local mg, cut ; \n if nops(fu)=2 then RETURN(convert(op(2,fu), string)) fi; \n cut:= 2*ceil(nops(fu)/4.) : mg:= fu[1..cut] ;\n \" if \", convert(m g[-2], string), \" then \", procname(x, mg), \n \" else \", procname( x, fu[cut+1..-1]), \" fi \" ; \nend :\naction(x,convert(fun(x), list)) ; cat(\"proc(x);\", %, \"end;\"); parse(%); end ;" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "ever_load:= ever_load, ra, xlgm_ini, xlgm , xpie2proc :" }}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 13 "Interpolation " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1521 "newraph:= proc(x, F, f , initpoint, leftbarrier) \nlocal F1, F2, f1, f2, x1, x2, x1e, x2e, ol ddigits, status_ok, hasleftbarrier, correction;\noption `Copyright (c) revisited.`;\n if 4 < nargs then hasleftbarrier := true else hasleftb arrier := false end if;\n olddigits := Digits;\n Digits := Digits + 5; \n if nargs < 4 then x1 := 0 else x1 := initpoint end if;\n status_ok \+ := 'false';\n F1 := evalf(F(x1) - x);\n f1 := evalf(f(x1));\n x1e := e valf(x1, olddigits);\n userinfo(4, stats, '`Newton-Raphson: x1,F1,f1`' , x1, F1, f1);\n to 100 do\n x2 := evalf(x1 - F1/f1);\n if hasleftba rrier and x2 < leftbarrier then\n correction := traperror(1.01^(x2 - leftbarrier));\n if x1 - leftbarrier < 1 then correction := 1/100*c orrection*(x1 - leftbarrier) end if;\n x2 := leftbarrier + correctio n\n end if;\n if not type(x2, \{numeric, float\}) then error \"x2 is not numeric\" end if;\n F2 := evalf(F(x2) - x);\n f2 := evalf(f(x2) );\n x2e := evalf(x2, olddigits);\n userinfo(4, stats, '`x2,F2,f2`', x2, F2, f2);\n if x1e = 0 and x2e = 0 or evalf(abs(x2 - x1)/(abs(x1) + abs(x2))) < Float(1, -olddigits - 1) then\n status_ok := 'true'; \+ break\n end if;\n x1 := x2;\n x1e := x2e;\n F1 := F2;\n f1 := f2 \n end do;\n if status_ok then userinfo(3, stats, '`Newton-Raphson, re sidual is`', F2)\n else userinfo(2, stats, '`Newton-Raphson, broke out after 100 iterations, residual is`', F2, \n '` x1-x2 is `', x1 - x2 )\n end if;\n Digits := olddigits;\n userinfo(4, stats, 'F2 - F1, f2 - f1, x2 - x1', F2 - F1, f2 - f1, x2 - x1);\n RETURN(evalf(x2))\nend pr oc;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "ever_load:= ever_loa d, newraph;" }}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 13 "lois usuelles" } }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 74 "unprotect('gauss', 'norlaw' , 'Norlaw', 'INorlaw', 'chi2', 'Chi2', 'IChi');" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 299 "norlaw:= unapply(`stats/statevalf/pdf/functio ns/normald`(t,m,s), m,s,t);\nNorlaw:= proc(m, s,t) evalf(1/2*'erfc'((m -t)/s/sqrt(2)))end;\nINorlaw:= (m,s,t)->stats[statevalf,icdf,normald[m ,s]](t):\ngauss:= unapply(norlaw(0,1,t),t);\nGauss:= t-> evalf(1/2*erf c(-1/2*t*sqrt(2)));\nIGauss:= t-> INorlaw(0,1,t);" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 211 "INorlaw:= proc(m,s,x) option `Copyright rev isited`;\nglobal `stats/statevalf/appxinvnormal`, newraph;\n evalf( ne wraph(x, y-> Norlaw(m,s,y), y-> norlaw(m,s,y), `stats/statevalf/appxi nvnormal`(x)*s + m))\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 83 "seq(k=INorlaw(10, 3, evalf(Norlaw(10,3,k), Digits+2) ), k=2..2 0): map(ASSERT, [%]):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 99 "gamma_law:= (x,a)-> x^(a-1 )*exp(-x/1)/GAMMA(a)/1^a;\nchi2:= unapply(gamma_law(x/2, nu/2)/2, x, n u); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 206 "chi2:= unapply(`st ats/statevalf/pdf/functions/chisquare`(t,nu), nu,t);\nChi2:= unapply(` stats/statevalf/cdf/functions/chisquare`(t,nu), nu,t);\nIChi:= (nu,t)- >`stats/statevalf/icdf/functions/chisquare`(t,nu):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 418 "IChi:= proc(nu, x) local appx; option `Cop yright revisited`;\nglobal `stats/statevalf/appxinvnormal`, newraph;\n if 100 < nu then appx := evalf(1/2*(`stats/statevalf/appxinvnormal`(x ) + sqrt(2*nu - 1))^2)\n else appx := evalf(nu*(1 - 2/9*1/nu + sqrt(2/ 9*1/nu)*`stats/statevalf/appxinvnormal`(x))^3)\n end if; \n if appx < \+ 1/100000 then appx := 1/100000 end if;\n newraph(x, y-> Chi2(nu,y), y- > chi2(nu,y), appx, 0)\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "seq(k=IChi(10, Chi2(10,k)),k=2..20): map(ASSERT, [%]) :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 91 "protect('gauss', 'Gauss', 'IGauss', 'norlaw', \+ 'Norlaw', 'INorlaw', 'chi2', 'Chi2', 'IChi');" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 98 "ever_load:= ever_load, norlaw, Norlaw, INorlaw, \+ gauss, Gauss, IGauss, gamma_law, chi2, Chi2, IChi;" }}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 76 "Routines r\351\351crites (xtally, histo, xcompa r_histo, histo_arr, chi2_tst, xcov)" }}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 30 "xtally (ne PAS utiliser tally)" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 233 "unprotect(`simul/islessequal`);\n`simul/islessequal` := proc(a,b) global `stats/islessequal`; \n`stats/islessequal`(a,b); \+ \nif member(%, \{true, false\}) then return % else error \"can't compa re \",a,b fi; \nend: protect(`simul/islessequal`);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 909 "`simul/tally`:= \nproc(data, topname) glob al tally_table, Weight, `stats/data`, `stats/abort`;\nlocal count, ite m, valeur;\noption `Copyright (c) 1993 by Waterloo Maple Inc. All righ ts reserved.`;\n if nargs <> 2 then RETURN(`stats/abort`(topname, \n \+ [topname, '`Incorrect number of arguments`'], [args]))\n end if;\n if not type(data, `stats/data`) then RETURN(`stats/abort`(topname, \n \+ [topname, '`requires data of type stats/data, received`', data], [args ]))\n end if;\n tally_table := table();\n for item in data do\n if ty pe(item, function) and op(0, item) = 'Weight' \n then valeur := op( 1, item); count := op(2, item)\n else valeur := item; count := 1\n \+ end if;\n if assigned(tally_table[valeur]) then tally_table[valeur] \+ := tally_table[valeur] + count\n else tally_table[valeur] := count\n \+ end if\n end do;\nmap(Weight@op, (op@eval)(tally_table));\ntry sort(% , `simul/islessequal`);\ncatch : %\nend try \nend;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 282 "`simul/xtally`:= proc() \noption `Copyri ght (c) 2002 by PLD. All rights reserved.`;\nglobal `stats/transform/f unctions/tally`;\n stats['transform', 'tally'](['red', 'blue', 'red'] ):\n `stats/transform/functions/tally`:= eval(`simul/tally`):\n stat s['transform', 'tally'](args); \nend;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 138 "simul[xtally]:= `simul/xtally` :\never_load:= ever_l oad, `simul/islessequal`, `simul/tally` : \nxsavelib(`simul/xtally`, \+ \"simul/xtally.m\") :" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 37 "xcutn \+ (g\350re les colonnes extremales) " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1003 "`simul/xcutn`:= proc(li_::list,n::positive) global \+ count: \nlocal li, j, M, res, yet, oldyet,base,base2,top,delta,k;\nli := `simul/xtally`(li_); M:= count(li); res:= array(1..n);\nj:=1; top:= M/n; oldyet:=0; yet:=0; \nop(1,li[1]); base:= `if`(type(%,range),lhs( %),%);\nfor k from 1 to nops(li) do yet:=yet+op(2,li[k]);\nif yet >= t op then \n base2:= op(1,li[k]); if type(base2,range) then base2:= rhs( base2)\n elif j " 0 "" {MPLTEXT 1 0 74 "simul[xcutn]:= `s imul/xcutn` : \nxsavelib(`simul/xcutn`, \"simul/xcutn.m\") :" }}}} {SECT 0 {PARA 4 "" 0 "" {TEXT -1 21 "histo : histogrammes " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "macro(old_histo= `stats/statplots/f unctions/histogram`);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5130 " `simul/xhisto`:= proc() global Weight, `stats/statplots/plotformat`,\n `stats/statplots/plot_options`, `stats/data`, lasterror;\nlocal clean , common, datarange, equal, extra, plotargs, plotcommand, i, jj, nclas ses, npoints, queuelh, queuerh, scaleby, scalef, splitdata, splitdata2 , tallied, viewing, width, dim, data, num, lines, numlines, polys, num polys, xtra, x, y, r, temp;\noption `Copyright (c) 2003-2005 - PLD for the fixes to all these many bugs !!! `;\n## area= ??? ; \n plotargs \+ := NULL; extra:='extra' ;\n dim := 0;\n data := array(1 .. nargs);\n s calef := 1;\n equal := false;\n nclasses := 0;\n for i to nargs do\n \+ if type(args[i], `stats/data`) then dim := dim + 1; data[dim] := args[ i]\n elif type(args[i], `=`) then\n if rhs(args[i]) = NULL then err or \"bad argument NULL %1\", args[i]\n elif lhs(args[i]) = 'area' th en\n temp := rhs(args[i]);\n if type(temp, name) then\n scal ef := traperror(stats['describe', temp]);\n if temp = lasterror th en error \"bad argument to area= %1\", temp end if\n elif type(temp , numeric) then scalef := temp\n else error \"bad argument to area= %1\", temp\n end if;\n equal := true\n elif lhs(args[i]) = 'n umbars' then\n nclasses := rhs(args[i]);\n if not type(nclasses, constant) or nclasses <= 0 or frac(nclasses) <> 0 then\n error \" bad argument to numbars= %1\", nclasses\n end if\n else plotargs \+ := plotargs, args[i]\n end if\n else error \"bad argument to histog ram %1\", args[i]\n end if\n end do;\n if dim = 0 then error \"empty \+ plot\" end if;\n if 1 < dim then\n plotcommand := 'PLOT3D';\n plotar gs := plotargs, 'orientation' = [75, 165];\n plotargs := `stats/statp lots/plot_options`(dim + 1, plotargs)\n else plotcommand := 'PLOT'\n e nd if;\n num := add(nops(data[i]), i = 1 .. dim);\n lines := array(1 . . num);\n numlines := 0;\n polys := array(1 .. num);\n numpolys := 0; \n xtra := NULL;\n for i to dim do\n clean := stats['transform', 'del etemissing'](data[i]);\n tallied := stats['transform', 'tally'](clean );\n datarange := stats['describe', 'range'](clean);\n if dim = 1 th en\n temp := 1/10*op(2, datarange) - 1/10*op(1, datarange);\n view ing := op(1, datarange) - temp .. op(2, datarange) + temp;\n plotarg s := `stats/statplots/plot_options`(dim + 1, 'view' = [viewing, 'DEFAU LT'], plotargs)\n else xtra := i - 1 .. i - .5\n end if;\n scaleby \+ := scalef(data[i]); \n npoints := nops(tallied); \n if not hastype( tallied, 'range') then\n if nclasses = 0 then \n nclasses := flo or(piecewise(npoints < 30, 1/4*npoints + 1, 4 + log(8*npoints)))\n e nd if;\n if equal then\n width := (op(2, datarange) - op(1, datar ange))/nclasses;\n if width = 0 then width := 1 end if;\n tallie d := stats['transform', 'tallyinto'[extra]](tallied,\n [seq(op(1, \+ datarange) + j*width .. op(1, datarange) + (j + 1)*width, \n j \+ = 0 .. nclasses - 1)]);\n tallied := stats['transform', 'statsort'] (tallied);\n if extra <> 'extra' then\n tallied := subsop(-1 = \+ Weight(op(stats['transform', 'statvalue']([tallied[-1]])),\n stat s['describe', 'count']([tallied[-1], op(extra)])), tallied);\n ext ra := 'extra'\n end if;\n scaleby := scaleby/stats['describe', ' count'](tallied); \n tallied := stats['transform', 'scaleweight'[sc aleby]](tallied)\n else\n splitdata := stats['transform', 'split' [nclasses]]\n (stats['transform', 'statsort'](tallied));\n \+ splitdata := map((x, N) -> \n Weight(stats['describe', 'ran ge'](x), N), splitdata, scaleby/nclasses); \n splitdata2 := NULL;\n queuelh := op(1, splitdata);\n splitdata := subsop(1 = NULL, sp litdata);\n queuelh := op(stats['transform', 'statvalue']([queuelh] )), stats['describe', 'count']([queuelh]);\n queuelh := op(1, queue lh[1]), op(2, queuelh[1]), queuelh[2];\n while 0 < nops(splitdata) \+ do\n queuerh := op(1, splitdata);\n splitdata := subsop(1 = NU LL, splitdata);\n queuerh := op(stats['transform', 'statvalue']([q ueuerh])), stats['describe', 'count']([queuerh]);\n queuerh := op( 1, queuerh[1]), op(2, queuerh[1]), queuerh[2];\n common := 1/2*que uelh[2] + 1/2*queuerh[1];\n splitdata2 := splitdata2, Weight(queue lh[1] .. common, queuelh[3]);\n queuelh := common, queuerh[2], que uerh[3]\n end do;\n tallied := [splitdata2, Weight(queuelh[1] .. queuelh[2], queuelh[3])]\n end if\n else \n scaleby:= scaleby/s tats['describe', 'count'](tallied); \n tallied:=[seq(Weight(op(1,k) ,op(2,k)*scaleby), k=tallied)]; \n end if;\n for jj to nops(tallie d) do\n if type(tallied[jj], function) and op(0, tallied[jj]) = 'Wei ght' then\n x := op(1, tallied[jj]); y := op(2, tallied[jj])\n el se x := tallied[jj]; y := 1\n end if;\n if type(x, range) then\n \+ r := op(2, x) - op(1, x);\n if r <> 0 then y := y/r end if;\n \+ numpolys := numpolys + 1;\n polys[numpolys] := [x, 0 .. y, xtra]\n \+ else\n if dim = 1 then numlines := numlines + 1; lines[numlines] \+ := [x, 0 .. y, xtra]\n else numpolys := numpolys + 1; polys[numpoly s] := [x, 0 .. y, xtra]\n end if\n end if\n end do\n end do;\n t emp := plotcommand(\n `stats/statplots/plotformat`([], convert(lines, list)[1 .. numlines], convert(polys, list)[1 .. numpolys]),\n plotar gs)\nend proc; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2502 "`simul/histo`:= proc(stt:: \{array, list\}, kmax_) \nglobal Weight, old_histo, displayf, xoption; \nlocal i, ii, count, siz, kmax, interv, mino, maxo, tally, st, \n s av_value, xla_value, fun_value, eps_value, ran_value, fac_value, opt; \nopt := [args[3 .. -1]]; \n fac_value := xoption(opt, 'fac', false); \n fun_value := xoption(opt, 'fun', false);\n ran_value := xoption(opt , 'ran', false);\n sav_value := xoption(opt, 'sav', false);\n xla_valu e := xoption(opt, 'xla', 0);\n# fus_ := xoption(opt, 'fus', 1);\n# cut _ := xoption(opt, 'cut', false);\n \nopt:= op(opt):\nif type(stt, arra y) then st := stt; siz := op(2, op(2, eval(st)))\n else siz := nops(st t); st := array(sort(stt))\nfi;\nmino := st[1]; maxo := st[siz]; \n if ran_value=false \n then # ran_value not assigned\n if typematch(kmax _, identical('eps') = eps_value::anything)\n then kmax:= (maxo-mino) /eps_value+1\n else kmax:= kmax_ ; eps_value:= (maxo-mino)/(kmax-1); \n fi; \n else \n if lhs(ran_value)maxo then maxo:= rhs(ran_value) fi; \n if typematch(kmax_, identical('eps') = eps_value::anything)\n then km ax:= (maxo-mino)/eps_value\n else kmax:= kmax_ ; eps_value:= (maxo- mino)/(kmax);\n fi; \n fi:\ninterv := seq(mino+eps_value*gk, gk = 0 ..kmax);\n if opt <> NULL then opt := \n 'view' = [mino+xla_value .. interv[-1]+xla_value, 'DEFAULT'], opt \n fi;\n ii := 1;\n count := 0; \n tally := NULL;\n for i to siz do\n if st[i] < interv[ii + 1] then \+ count := count + 1\n else\n tally := tally, Weight(interv[ii] + xla _value .. interv[ii + 1] + xla_value, count);\n count := 0;\n i := i - 1;\n ii := ii + 1\n fi\n od;\n tally := [tally, Weight(interv[ ii]+ xla_value .. interv[ii + 1]+ xla_value, count)];\nif sav_value <> false then map( \n proc(x,y) local a,b,c; typematch(x, Weight(a::anyt hing..b::anything, c::anything));\n Weight(a-y..b-y,c); end, tally, xl a_value); assign(eval(sav_value,1), array(%) );\nfi;\n\nif fun_value < > false then\n if fun_value='delta' then fun_value:= 1/(interv[-1]-int erv[1]) fi;\n if has(fun_value, floor) \n then opt:= plots['pointplot ']([ mino+xla_value,0, seq(\n op([gk+xla_value,fun_value(gk), gk+1+ xla_value,fun_value(gk), gk+xla_value+1,0]),\n gk=mino..maxo-1)], ' style'='line'), opt;\n else \n opt:= plot(['x'+xla_value,fun_value(' x'), 'x'=mino .. interv[-1]], 'color'='black'),opt;\n fi;\nfi;\n if f ac_value= false then fac_value:= siz; fi;\n map(proc(z, fac_) subsop(2 = op(2, z)/fac_, z) end, tally, fac_value);\n displayf(old_histo(%, ' color'='gray'), opt)\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 151 "simul[histo]:= `simul/histo` : xsavelib(`simul/histo`, \"simul/hi sto.m\") :\nsimul[xhisto]:= `simul/xhisto` : xsavelib(`simul/xhisto`, \+ \"simul/xhisto.m\") :" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 13 "xcompa r_histo" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 437 "`simul/xcompar_h isto`:= proc(ex::list, th::list) global mihis, display, xhisto; \nloca l nn; nn:= nops(th); \nif map2(op,1,ex) <> map2(op,1,th) then \n err or '`: les deux structures n'ont pas le m\352me support`'\nfi;\nmihis: = [seq('Weight'( op(1,th[j]), min(op(2,th[j]),op(2,ex[j]))), j=1..nn) ]; \ndisplay(xhisto(mihis, 'color'='grey', args[3..-1]), xhisto(ex, ' color'='cyan', args[3..-1]) \n, xhisto(th, 'color'='yellow', args[3..- 1]));\nend: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 106 "simul[xcom par_histo]:= `simul/xcompar_histo` : \nxsavelib(`simul/xcompar_histo`, \"simul/xcompar_histo.m\") :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 28 "histo_arr : histo from simul" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1930 "`simul/histo_arr `:= proc(stt::array) global displayf, Weight, old_histo, xoption; \nl ocal Qloc, i, k, kmax, mino, maxo, tally, \nfus_, ran_, sav_, xla_, fu n_, fac_, eps_, cut_, opt;\n opt := [args[2 .. -1]];\n fus_ := xoption (opt, 'fus', 1);\n fac_ := xoption(opt, 'fac', false);\n fun_ := xopti on(opt, 'fun', false);\n ran_ := xoption(opt, 'ran', false);\n sav_ := xoption(opt, 'sav', false);\n xla_ := xoption(opt, 'xla', 0);\n cut_ \+ := xoption(opt, 'cut', false);\n\n opt := op(opt);\nif cut_ <> false t hen \n opt:= opt, 'view' = [op(1,cut_)+xla_ .. op(2,cut_)+xla_, 'DEFA ULT']; \nfi;\n\n Qloc:= op(2, op(2, eval(stt))); # for Qloc1 from Qloc by -1 while stt[Qloc1]=0 do od; \n \nif (ran_=false) then ERROR (\"mi ssing ran parameter\") fi;\n mino := lhs(ran_); maxo:= rhs(ran_);\n ep s_:= (maxo-mino)/Qloc*fus_;\n kmax:= floor(Qloc/fus_); maxo:= mino+(km ax+1)*eps_;\n\ntally := NULL; i := 'i';\nfor k from 0 to kmax-1 do \n \+ tally := tally, Weight(mino + eps_*k+ xla_ .. mino + eps_*(k+1)+ xla_, \n add(stt[k*fus_+i], i=0..fus_-1) );\nod; tally := [ tally, Weight(mino + eps_*kmax+ xla_ .. mino + eps_*(kmax+1)+ xla_,\n \+ add(stt[i], i=kmax*fus_..Qloc) )];\n \nif sav_ <> fals e then\n map(proc(x, y) local a, b, c;\n typematch(x, Weight((a::a nything) .. (b::anything), c::anything)); \n Weight(a - y .. b - y, c)\n end, tally, xla_); assign(eval(sav_, 1), array(%) )\nfi;\n\nif fun_ <> false then\n if fun_ = 'delta' then fun_ := 1/(maxo - mino) f i;\n if has(fun_, floor) \n then opt := plots['pointplot']([mino + xl a_, 0, seq(\n op([gk + xla_, fun_(gk), gk + 1 + xla_, fun_(gk), gk + 1 + xla_, 0]),\n gk = mino .. maxo - 1)], 'style' = 'line'), opt\n \+ else \n opt := plot(['x' + xla_, fun_('x'), 'x' = mino .. maxo], 'c olor' = 'black'),\n opt;\n fi\nfi;\n\nif fac_ = false then fac_ : = add(stt[i], i=0..Qloc) fi;\n\nmap(proc(z, fac_) subsop(2 = op(2, z)/ fac_, z) end, tally, fac_);\ndisplayf(old_histo(%, 'color' = 'gray'), \+ opt)\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 90 "simul[histo_a rr]:= `simul/histo_arr` : \nxsavelib(`simul/histo_arr`, \"simul/histo_ arr.m\") :" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 25 "chi2_tst : test d u chi_2 " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "tri_xy:= proc(x, y) evalb(op([1,1],x) " 0 "" {MPLTEXT 1 0 1695 "`simul/chi2_tst`:= proc(hist, law) \nglobal chisqua re, hist1_, hist2_, Weight, xoption, concat, transpose, ``; \nlocal k , xx, nu, a1, b1, c1, a2, b2, c2, opt, verb_, seuil_;\na1:='a1':a2:='a 2':b1:='b1':b2:='b2':c1:='c1':c2:='c2':\nopt := [args[2 .. -1]];\nverb _ := xoption(opt, 'verb', false);\nseuil_ := xoption(opt, 'seuil', 5); \n\n map(proc(z) if type(z, range) then Weight(z, 1) else z fi end, co nvert(hist, list));\n hist1_ := sort(%, 'tri_xy');\n k := 1;\n while k < nops(hist1_) do\n typematch(hist1_[k], Weight(('a1'::numeric) .. ( 'b1'::numeric), 'c1'::numeric));\n if c1 < seuil_ then\n typematch( hist1_[k + 1], Weight(('a2'::numeric) .. ('b2'::numeric), 'c2'::numeri c));\n hist1_ := subsop(k = NULL, k + 1 = Weight(a1 .. b2, c1 + c2), hist1_)\n else k := k + 1\n fi\n od;\n while 1 < k do\n typematch( hist1_[k], Weight(('a1'::numeric) .. ('b1'::numeric), 'c1'::numeric)); \n if c1 < seuil_ then\n typematch(hist1_[k - 1], Weight(('a2'::num eric) .. ('b2'::numeric), 'c2'::numeric));\n hist1_ := subsop(k = NU LL, k - 1 = Weight(a2 .. b1, c1 + c2), hist1_);\n k := k - 1\n else break\n fi\n od;\n hist2_ := map(proc(z, laww) local t, qq; t := 't' ; \n if has(laww, floor) \n then qq:= add(laww(t), t= op([1,1],z)..o p([1,2],z)-1) \n else qq:= evalf(Int(laww(t), t = op(1, z)))\n fi; [ op([1, 1], z), op(2, z), qq, (op(2,z)-qq)^2/qq] \n end, hist1_, law); \n\n if verb_ then \n #print(matrix([map(round,%[1]), %[2], map(round ,%[3])])); \n print(map(round, concat(transpose(%), [op([-1, 1, 2], h ist1_), ``, ``, 'chi^2'])))\n fi;\n map2(op,4,hist2_);\n nu := nops(%) - 1;\n xx := convert(%%, `+`);\n stats['statevalf', 'cdf', chisquare[ nu]](xx);\n 'deg_lib' = nu, 'x' = evalf(xx, 4), 'percent' = evalf(%, 3 )\nend: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 95 "simul[chi2_tst] := `simul/chi2_tst` : \nxsavelib(`simul/chi2_tst`, tri_xy, `simul/chi 2_tst.m`) :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 4 "xcov" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 517 "toto:= convert(eval(`stats/describe/functions/covari ance`), string):\nsearchtext(\"sum := sum+\", toto):\ntoto:= cat(subst ring(toto, 1..%+10), \"item_count1*\", substring(toto, %+11..-1)):\nde b:= searchtext(\"Copyright\", toto): fin:= searchtext(\"reserved.`\", \+ toto[deb..-1]):\ncat(substring(toto,1..deb-1), \"Copyright (c) 2005 by Pierre L. Douillet. Only authorized persons can use the correct algor ithm. All other people ***MUST*** use the buggy original Waterloo vers ion\", substring(toto, deb+fin+8..-1)): \nxcov:= parse(%); " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "ever_load:= ever_load, xcov; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 29 "Simulation de files d'attent e" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 50 "new_client (permet la gestion de srv0 et de resi0)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "unprotect(new_client):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 427 "new_client:= proc() global agenda, charg e, arv, srv; local arv0, srv0, i, resi0;\n arv0, srv0 := arv(), srv(); \n if nops(agenda)=0 then resi0:=0 else resi0:= op(1, agenda[1]) fi;\n charge := charge + srv0;\n agenda := [op(agenda), [charge, 'D']];\n f or i to nops(agenda) do if arv0 < agenda[i][1] then break end if end d o;\n agenda := [op(agenda[1 .. i - 1]), [arv0, 'A'], op(agenda[i .. -1 ])];\n client_observe(srv0, resi0)\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 9 "evol_file " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 300 "`simul/evol_file`:= proc() glo bal agenda, charge; local quoi, delai, nature;\nserveur_observe(); \nq uoi:= agenda[1]; delai, nature:= op(quoi); \nagenda:= [seq([agenda[j] [1]-delai, agenda[j][2]], j=2..nops(agenda))];\ncharge:= max(charge-de lai,0);\nif nature = 'A' then new_client() fi; return NULL ;\nend:" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 15 "serveur_observe" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 229 "unprotect(serveur_observe):\nserveur_observe:= \+ proc() global durees, agenda; local n, delai;\nn:= nops(agenda)-1; del ai:= agenda[1][1];\nif type(durees[n], numeric) then durees[n]:= duree s[n]+delai; else durees[n]:= delai; fi; \nend:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 14 "client_observe" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 226 "unprotect(client_observe):\nclient_observe:= proc(srv0) global ag enda, sejours, attentes, numcli, charge, autres;\nnumcli:=numcli+1: se jours[numcli]:= charge; attentes[numcli]:= charge-srv0;\nautres[numcli ]:= nops(agenda)-2;\nend:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 93 "raz_ file (permet la gestion des tables g\351r\351es par clients : sejours, attentes, autres, resid)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 260 "`simu l/raz_file`:= proc() \nglobal agenda, charge, sejours, attentes, numcl i, durees, autres, resid;\n agenda, charge := [[0, 'A']], 0;\n durees \+ := table();\n sejours, numcli := table(), 0;\n attentes := table();\n \+ autres := table(); resid:= table();\n NULL\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 135 "simul[evol_file]:= `simul/evol_fil e` : \nxsavelib(`simul/evol_file`, new_client, serveur_observe, client _observe, `simul/evol_file.m`) :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 86 "simul[raz_file]:= `simul/raz_file` : \nxsavelib(`simu l/raz_file`, `simul/raz_file.m`) :" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 5 "Infos" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "interface(rtablesize=30):" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 90 "(op@eval)(simul): sort(%, \+ proc(a,b) lexorder(lhs(a) , lhs(b)) end): 'elements' = ; " }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 58 "'ever_loaded' = < (op@sort)(convert (\{ever_load\}, list)) >;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 119 "ever_load:= op(\{ever_load\}):\never_load_list:= map(proc(z) cat( ` `,z) end, sort([ever_load]));\nsimul['ever_loaded']:= %:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 118 "simul6:= proc() option package; en d;\nsimul6('_InitFile'):= eval(`simul/init`);\nsimul6('_PackageTable') := eval(simul); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 29 "xsavelib(simul6, `simul6.m`);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 72 "xsavelib('simul', `simul/init`, ever_load, 'e ver_load_list', `simul.m`);" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 8 "Contr\364le" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 86 "protect(`simul/xtally`, client_obse rve, new_client, serveur_observe):\n_seed:= '_seed':" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "eval(ssavelib, 1);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "lasterror:= 'lasterror' : map(xmint, sort(eval([ssavelib],1), lexorder)): " }}}}{EXCHG {PARA 258 "" 0 "" {TEXT -1 64 "Copyright (c) 1999-2007 Pierre L. Douillet \n" }}{PARA 258 "" 0 "" {TEXT -1 11 "licence GPL" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 258 "" 0 "" {TEXT -1 195 "libre \+ reproduction pour un usage universitaire sous reserve d'une copie comp l\350te,\navec reproduction du programme source dont, en particulier, \+ la pr\351sente mention\n \n\naucune garantie de fiabilit\351. " }} {PARA 258 "" 0 "" {TEXT -1 89 "en particulier, toute utilisation dans \+ un contexte industriel est vivement d\351conseill\351e\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "1;" }}}}{MARK "22" 0 }{VIEWOPTS 1 1 0 3 2 1804 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }