10.17GeneratingRandomNumbersinQuestions
Thealgorithmsyntaxinthesystemallowsyoutogeneraterandomnumbersinavarietyofways,dependingonyour
requirementsandpreferences.Thistablesummarizesfunctionsrelatedtorandomnumbergeneration.
Table10.9:RandomNumberGenerators
Description
Example
RangeofOperation
Function
Returnsarandomintegerbetween
0andn-1(inclusive).Generatesn
variations.
rint(3)
=0,1,or2
0,...,n-1
rint(n)
Returnsarandomintegerbetween
mandn-1(inclusive).Generates
n-mvariations.
rint(3,6)
=3,4,or5
m,...,n-1
rint(m,n)
Returnsarandomintegerbetween
mandn-1(inclusive)instepsofk.
rint(3,12,3)
=3,6,or9
m,m+k,m+2k,...,m+q*k
(whereqisthelargestinteger
suchthat
)
rint(m,n,k)
Generatesapproximately(n-m)/k
variations.
Returnsarandomintegerbetween
1andn(inclusive).Generatesn
variations.
range(3)
=1,2,or3
1,...,n
range(n)
Returnsarandomintegerbetween
mandn(inclusive).Generates(n-
m)+1variations.
range(3,6)
=3,4,5,or6
m,...,n
range(m,n)
Returnsarandomintegerbetween
mandn(inclusive),instepsofk.
range(3,12,3)
=3,6,9,or12
m,m+k,m+2k,...,m+q*k
(whereqisthelargestinteger
suchthat
)
range(m,n,k)
Generatesapproximately(n-m)/k
+1
variations.
Returnsarandomrealnumber
betweenmandn(inclusive).
rand(0.5,9.5)
=allrealnumbersbetween0.5
and9.5(inclusive)
m,...,n
rand(m,n)
Returnsarandomrealnumber
betweenmandn(inclusive),ex-
pressedtoksignificantfigures
rand(0.5,9.5,3)
=allrealnumbersbetween0.5
and9.5(inclusive),expressed
to3significantfigures
m,...,nexpressedtoksignific-
antfigures
rand(m,n,k)
Fordetailsoneachofthesefunctions,seeFunctionsandArguments(page242).
InadditiontoMapleT.A.'sbuilt-infunctions,youcanaccessMaple
TM
commands.Mapleprovidesmanyrandomization
commands.ThefollowingtablelistsselectedrandomizationcommandsinMaple.FormoreinformationonMaple
functionsthatcanbeusedtogeneraterandomnumbers,refertoyourMapledocumentation.
Table10.10:MapleRandomizationCommands
Use
MapleFunction
generatearandom12-digitnon-negativeinteger,orarandomintegerwithinaspe-
cifiedrange(inclusive)
rand
randompolynomialgenerator
randpoly
constructarandomMatrix
LinearAlgebra[RandomMatrix]
10.17GeneratingRandomNumbersinQuestions • • 241
Append pdf - Merge, append PDF files in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Provide C# Demo Codes for Merging and Appending PDF Document
add multiple pdf files into one online; combine pdfs online
Append pdf - VB.NET PDF File Merge Library: Merge, append PDF files in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET Guide and Sample Codes to Merge PDF Documents in .NET Project
c# combine pdf; add pdf files together online
Use
MapleFunction
constructarandomVector
LinearAlgebra[RandomVector]
generateaparticularrandomobject(Forexample,returnarandomcomplexnumber
withrealandimaginarypartsofaspecifiedflavor,orchooseoneoftheentriesin
acollectionwithequalprobability)
RandomTools[Generate]
Note:WhenusingMaple'srandomnumbergeneratorrand,youmustincluderandomize():asthefirstpartofthecall.
Thissetstheinitialstateoftherandomnumbergeneratorusinganumberbasedonthesystemclockinsteadofthe
defaultseedinMaple.Withoutrandomize(),eachcalltorandwillproducethesamesequenceofvaluesusingthe
defaultrandomizationseed.ForanexamplethatusesMaplerandomizationcommands,seeTutorial:Maple-based
AlgorithmicQuestionAuthoring(page263).
SeeAlso:
Tutorial:AlgorithmicQuestion(page260)
Tutorial:List-basedVariables(page261)
Tutorial:Maple-basedAlgorithmicQuestionAuthoring(page263)
10.18FunctionsandArguments
Thesystemcontainsnumerousbuilt-infunctionsforcreatingalgorithmicvariables.Youcancreaterandomintegers
orrealnumbers,performoperationsonlistsofitems,orsetconditionsonvariables.
Thissectiondescribesthebuilt-infunctions,andgivesthesyntaxandpurposeofeachfunction.
Mostofthesefunctionsareforuseinauthoringquestions,butcannotbeusedinstudentresponses.Formoreinformation,
seeMathematicalandLogicalOperatorsinAlgorithmsandAnswers(page252).
condition:x
condition:x
Imposestheconditiondefinedbystatementx,whichistypicallyconstructedusingoneormoreotherfunctions.
Forexample,
$a=range(-10,10);
condition: ne($a,0);
Thisgeneratesarandomnon-zerointegerbetween-10and10(inclusive).
decimal(n,x),sig(n,x),int(x)
decimal(n, x)
Returnsxexpressedasafloating-pointnumberroundedtondecimalplaces.Whendecimal(0,expression)isused
withanexpression,thesystemautomaticallyinsertscommastoseparatethousands.
Trailingzerosaretruncatedandnotdisplayed.Foranotheroption,seenumfmt(fmt,x)(page247).
sig(n, x)
Returnsxexpressedasafloating-pointnumberroundedtonsignificantdigits.Incasesofpossibleambiguity,scientific
notationisusedtodisplaythevalue.
int(x)
Returnstheintegerpartofx.
242 • 10AuthoringMathematicalQuestions
Online Merge PDF files. Best free online merge PDF tool.
Online Merge PDF, Multiple PDF files into one. Download Free Trial. Merge PDF, Multiple PDF files. Drag and drop your PDF or several files in the box above.
combine pdf; build pdf from multiple files
C# TIFF: C#.NET Code to Merge and Append TIFF Files
Merge and Append Tiff Files. How to Merge and Append TIFF Files in C# by Using RasterEdge XDoc.Tiff for .NET SDK. Merge and Append TIFF Files in C#.NET Overview.
acrobat merge pdf; add pdf pages together
Forexample,
decimal(3, 20.8571)
returns20.857
sig(3, 20.8571)
returns 20.9
int(20.8571)
returns
20
eq(a,b),ge(a,b),le(a,b),ne(a,b)
eq(a, b)
Returns1.0ifaandbareequal.Otherwise,itreturns0.0.
ge(a,b)
Returns1.0ifaisgreaterthan,orequaltob.Otherwise,itreturns0.
le(a,b)
Returns1.0ifaislessthan,orequaltob.Otherwise,itreturns0.0.
ne(a,b)
Returns1.0ifaandbarenotequal.Otherwise,itreturns0.0.
Forexample,
if(eq($a, $b), "Red", , "Green")
returnsRedif$a=$bandGreenotherwise.
if(ge($a, $b), "Red", , "Green")
returns Redif$a>=$bandGreenotherwise.
if(le($a, $b), "Red", , "Green")
returnsRedif$a<=$bandGreenotherwise.
if(ne($a, $b), "Red", , "Green")
returnsRedif$aand $barenotequalandGreenotherwise.
SeeAlso:
if(a,b,c)(page244)
fact(n)
fact(n)
Returnsfactorialn.
Ifnisnotanintegerreturnsfact(int(n)).
Ifnisnegative,returns1.
10.18FunctionsandArguments • • 243
VB.NET PDF Library SDK to view, edit, convert, process PDF file
Tell VB.NET users how to: create a new PDF file and load PDF from other file formats; merge, append, and split PDF files; insert, delete, move, rotate, copy
all jpg to one pdf converter; apple merge pdf
C# PDF Library SDK to view, edit, convert, process PDF file for C#
Tell C# users how to: create a new PDF file and load PDF from other file formats; merge, append, and split PDF files; insert, delete, move, rotate, copy and
c# merge pdf files into one; add pdf files together online
Forexample,
fact(4)
returns24
frac(a,b)
frac(a, b)
Thefrac(a,b)structuretypesetsx/yasafractioninitslowestterms.Forexample,thefractions"4/8"and
"2/6"arepresentedas"1/2"and"1/3",insimplestform.
frac(a,b)returnsastringthatexpressesthefractiona/binitslowestterms.
Forexample,
frac(12, 15)
returns4/5
frac(12, 3)
returns4
Note:frac(a,b)canbecombinedwithmathml(s)toproducenicelytypesetfractions.Forexample,
mathml(frac(8, 12))
displays
gcd(a,b)
gcd(a, b)
Returnsthegreatestcommondivisorofaandb.
Forexample,
gcd(12, 15)
returns3
gt(a,b),lt(a,b)
gt(a, b)
Returns1.0ifisgreaterthan b, that is (a > b).Otherwise,itreturns0.0.
lt(a, b)
Returns1.0ifislessthan b, that is (a < b).Otherwise,itreturns0.0.
if(a,b,c)
if(a, b, , c)
Ifaisnonzero,itreturnsb.Otherwise,itreturnsc.
244 • 10AuthoringMathematicalQuestions
C# PDF File & Page Process Library SDK for C#.net, ASP.NET, MVC
Jpeg. Convert PDF to Png, Gif, Bitmap Images. File and Page Process. File: Merge, Append PDF Files. File: Split PDF Document. File
pdf merge documents; pdf mail merge plug in
C# WPF PDF Viewer SDK to view, annotate, convert and print PDF in
Jpeg. Convert PDF to Png, Gif, Bitmap Images. File and Page Process. File: Merge, Append PDF Files. File: Split PDF Document. File
best pdf merger; batch combine pdf
indexof(k,a,b,c,d,...)
Returnstheindexofanitemwithinalist(thefirstitemisinposition0,thesecondinposition1,andsoon).
Forexample,
indexof(3, 2, 3, 5, 7, 11)
returns1
java(cn,a,b,c,d,...)
java(cn, a, b, c, d, ...)
Passtheargumentsa,b,c,d,..toacustomJava
TM
evaluationengineandreturntheresult.Thefirstargument
(cn)mustbeastringgivingthefullyqualifiednameofaJavaclassthatimplementstheinterface
gateway.question.random.AlgorithmicFunction.
Thisinterfacehasasinglepublicmethod.
public String eval(String[ ] args);
Theargumentsa,b,c,d,...arepassedtoeval()inastringarray.
Forexample,
java("com.mycompany.QuoteFunction", "SUNW")
returnsareal-timequoteforSunMicrosystems,Inc.stock(assumingthattheclassQuoteFunctionhadbeensuitably
programmed).
lsu(n,x)
lsu(n, x)
Returnstheunitinthenthsignificantplaceofx.(Thisiscalledtheleastsignificantunitofxinthenthplace).
Forexample,
lsu(3, 3.14159)
returns0.01(theunitinthethirdsignificantplace).
Thisoperationisdesignedtobeusedwhensettingthetoleranceforcorrectanswers.Forexample,toacceptananswer
towithinatoleranceofoneunitinthethirdsignificantdigit,use:
$ans
= <formula>;
$tol = lsu(3, $ans);
andsettheanswerfieldto:
$ans ? ? $tol
maple(text)
PasstexttotheMaple
TM
kernelandreturnthevalueofthelastlineprocessed.
10.18FunctionsandArguments • • 245
VB.NET PDF - WPF PDF Viewer for VB.NET Program
to Png, Gif, Bitmap Images. File & Page Process. File: Merge, Append PDF Files. File: Split PDF Document. File: Compress PDF. Page
adding pdf pages together; acrobat reader merge pdf files
VB.NET Create PDF from PowerPoint Library to convert pptx, ppt to
to Png, Gif, Bitmap Images. File & Page Process. File: Merge, Append PDF Files. File: Split PDF Document. File: Compress PDF. Page
add pdf files together reader; .net merge pdf files
Forexample,
maple("ithprime(12)")
returns37
maple("diff(sin(x)*x, x)")
returnscos(x)*x + sin(x)
SeeAlso:
MathematicalandLogicalOperatorsinAlgorithmsandAnswers(page252)
mathml(f)
ReturnsastringconsistingoftheformulaftypesetinMathML.
Note:ThesystemrendersMathML;theMathMLtagsdonotappearonthescreenwhenthevalueofthestringisdis-
played.Instead,therenderingappears.
Forexample,
mathml("x^$n")
returns
Bydefault,mathml(f)automaticallysimplifiestheformula.Topreventauto-simplification,usethe"nosimplify"
option.
Forexample,
mathml("x^2 + 4/8", , "nosimplify")
returns
Ifyouwanttoincludethefunctioninanotherfunction,usethe"notags"option.
$\sum0^\infty\var{mathml("1/$a x^2
+ $b)", "notags")}$
SeeAlso:
InlineDisplayofFormattedMathExpressions(page216)
SimplifiedMathExpressions(page219)
max(a,b,c,d,...),min(a,b,c,d,...)
max(a, b, c, d, ...)
Returnsthelargestofthearguments.
Forexample,
max(3,5,7,4.8,-1)
returns
246 • 10AuthoringMathematicalQuestions
7
min(a, b, c, d, , ...)
Returnsthesmallestofthearguments.
Forexample,
min(3, 5, 7, 4.8, -1)
returns
-1
not(a)
not(a)
Returns1.0ifaisequalto0.0.Otherwise,itreturns1.0.
numfmt(fmt,x)
Returnsthevalueofx,formattedaccordingtothetemplatefmt.
Forexample,
numfmt("#.00", 20.9)
returns20.90.
plotmaple(text)
MapleT.A.usesMaple
TM
plottingfeaturestodisplayplots.Mapleprovidesmanywaysofrepresentingdataand
mathematicalexpressionsgraphicallyusingplots.Youcandisplayaplotwithanyquestiontype.
Theplotmaplecommandcanbeusedanywhereanalgorithmicvariablecanbeused,thatis,intext,hints,feedback,
andmore.
plotmaple("plotstatement, libname='filename.lib', , plotdevice='gif|jpeg',
plotoptions='options'");
Where
• plotstatement - plotexpressionandplotoptions
• libname(optional)-specifiespathtouserMaplelibraries
• plotdevice(optional)-gif(producesaGIF/ANIMATED-GIF)orjpeg(producesa24-bitcolorJPEGren-
deringoftheimage)
• plotoptions(optional)-specifiesplotoptionsavailablefortheplotdevicespecified(seeTable10.11)
Someexamples:
plotmaple("plot3d(sin(x)*y, x=0..10, y=-1..1, style=patchnogrid, , lightmodel=light1),
plotdevice='jpeg', plotoptions='width=250,height=250'")
plotmaple("plot(sin(x), x=-Pi..Pi), plotdevice='gif', , plotoptions='height=250, width=250'");
10.18FunctionsandArguments • • 247
plotmaple("plot(sin(x), x=-Pi..Pi), plotdevice='jpeg', , plotoptions='height=250, , width=250'");
Table10.11:OptionsforGIFandJPEGPlots
result
GIFplotoptions
Setthenumberofcolors.Thedefault256colors.
colors=n
Setthenumberofpixelsintheheight.Thedefaultis512.
height=n
Setthenumberofpixelsinthewidth.Thedefaultis512.
width=n
result
JPEGplotoptions
Specifytheheightofthecanvas.Thedefaultis360.
height=n
SettheJPEGqualitylevel,anintegervaluefrom0to100.The
defaultis95.Settingsgreaterthan95generallyhavenegligible
visibleeffect.
quality=n
Specifythewidthofthecanvas.Thedefaultis480.
width=n
SeeAlso:
SettingPlotOptions(page255)
rand(m,n),rand(m,n,k)
rand(m,n)
Returnsarandomrealnumberbetweenmandn(inclusive).Forexample,togeneraterandomnumbersbetween0.5
and9.5,usetheformula:
rand(0.5, 9.5)
rand(m,n,k)
Returnsarandomrealnumberbetweenmandnexpressedtok(k>0)significantdigits(kistruncatedtoaninteger).
Forexample,togeneratenumbersbetween2.73and7.91totwosignificantfigures,use:
rand(2.73, 7.91, 2)
Note:Inthisdefinition,thedummyvariablekrepresentsthenumberofsignificantfigures,notthestepsize(asitindicatesinde-
finingrangeandrint).
Togeneraterandomnumbersthatvaryanorderofmagnitudeandhavethesamenumberofdecimaldigits,usethe
decimalfunctioninconjunctionwiththerandfunction.Forexample,togeneratearandomnumberbetween2and
20withonedecimalplace,use:
decimal(1, rand(2, 20, 3) )
Note:Numbersposingapossibleambiguityarereturnedusingscientificnotation.
SeeAlso:
decimal(n,x),sig(n,x),int(x)(page242)
RandomIntegerGenerationrange(n),range(m,n),range(m,n,k)(page248)
RandomIntegerGenerationrint(n),rint(m,n),rint(m,n,k)(page249)
GeneratingRandomNumbersinQuestions(page241)
RandomIntegerGenerationrange(n),range(m,n),range(m,n,k)
Therangefunctionreturnrandomintegers.
248 • 10AuthoringMathematicalQuestions
range(n)
Therange(n)functiongeneratesarandomintegerintherange1, ..., n(inclusive).Therearennumbersin
thatrange.Hence,itisaselectionofonenumberfromachoiceofn.
range(m,n)
Therange(m,n)functiongeneratesarandomintegerintherangem, ..., n(inclusive).
range(m,n,k)
Therange(m,n,k)functiongeneratesarandomintegerintherangem, m+k, ..., m+q*k(inclusive)where
qisthelargestintegersuchthatm+q*k<=n.
Thatis,
range(n) = = range(1,n) ) = range(1,n,1)
Examples
range(3)returns1,2,or3.
range(2,3)returns2or3.
range(0,7,3)returns0,3,or6.
range(0,8,3)returns0,3,or6.
range(0,9,3)returns0,3,6,or9.
Note:Therintfunctionreturnsrandomnumbersintherange0, ..., n-1(inclusive).
SeeAlso:
rand(m,n),rand(m,n,k)(page248)
RandomIntegerGenerationrint(n),rint(m,n),rint(m,n,k)(page249)
GeneratingRandomNumbersinQuestions(page241)
rank(n,a,b,c,d,...)
Returnsthenthlargestelementitemfromalist.(Numberingstartsat1)
Forexample,
rank(3, 2, 4, 6, 5, 7)
returns5
SeeAlso:
indexof(k,a,b,c,d,...)(page245)
switch(n,a,b,c,...)(page252)
RandomIntegerGenerationrint(n),rint(m,n),rint(m,n,k)
Therintfunctionreturnrandomintegers.
10.18FunctionsandArguments • • 249
rint(n)
Therint(n)functiongeneratesarandomintegerintherange0, ..., n-1(inclusive).Therearennumbersin
thatrange.Hence,itisaselectionofonenumberfromachoiceofn.
rint(m,n)
Therint(m,n)functiongeneratesarandomintegerintherangem, ..., n-1(inclusive).
rint(m,n,k)
Therint(m,n,k)functiongeneratesarandomintegerintherangem, m+k, ..., m+q*k(inclusive)where
qisthelargestintegersuchthatm+q*k<=n-k.
Thatis,
rint(n) = rint(0,n) = rint(0,n,1)
Examples
rint(3)returns0,1,or2.
rint(1,3)returns1or2.
rint(0,7,3)returns0or3.
rint(0,8,3)returns0or3.
rint(0,9,3)returns0,3,or6.
Note:Therangefunctionreturnsrandomintegersintherange0, ..., n(inclusive).
SeeAlso:
RandomIntegerGenerationrange(n),range(m,n),range(m,n,k)(page248)
rand(m,n),rand(m,n,k)(page248)
GeneratingRandomNumbersinQuestions(page241)
StatisticalOperations
binomial(n, r)
Computestherthbinomialcoefficientofdegreen.Thiscorrespondstothenumberofwaysofchoosingrobjects
fromasetofn,ignoringorder.Itisusedinsystemperformancestatistics,butisalsoavailableforuseininternaldir-
ectives(algorithmsandanswers).
Forexample,
binomial(22, 3)
returnsthecoefficientofx
19
in(x+1)
22
or1,540.
erf(z)
Computesthecumulativeprobability(probabilitythatavariateassumesavaluelessthanorequaltoz)forastandard
normaldistribution(thatis,withmean0andvariance1).
250 • 10AuthoringMathematicalQuestions
Documents you may be interested
Documents you may be interested