File:  [LON-CAPA] / loncom / html / adm / help / tex / Numerical_Response_Randomization.tex
Revision 1.4: download - view: text, annotated - select for diffs
Mon Sep 2 21:28:55 2013 UTC (10 years, 10 months ago) by raeburn
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0, HEAD
- per code previously included within lyxcode begin/end within verbatim
  begin/end instead.

\label{Numerical_Response_Randomization}

For LON-CAPA, one of the most important functions is the \texttt{random}
function. Random takes three parameters: a \emph{lower limit}, an \emph{upper
limit}, and an \emph{interval}. The \texttt{\&random} function returns a
random value between the upper and lower limit, some integer number of \emph{interval}'s
away from the lower limit. Thus, for example, \texttt{\&random(1,2,.2)} might
return 1, 1.2, 1.4, 1.6, 1.8, or 2. \texttt{\&random} uses a uniform distribution.
Other distributions are available in LON-CAPA, and can be found by consulting
the function list.

%
\begin{figure}
\begin{verbatim}
$a = &random(1.0,10.0,1.0);

$b = &random(-10.0,-3.0,1.0);

$answer = $a+$b;
\end{verbatim}

\caption{Sample \texttt{Random} Calls \label{Sample Random Calls figure}}
\end{figure}
If you put the script in ``Sample Random Calls'' into the
\textbf{Script} block (replacing whatever contents might be in the block
already), you'll get two random variables \$a and \$b. Now, in the \textbf{Text
Block}, put {}``What is \$a plus \$b?'', and in the \textbf{Answer} put
{}``\$answer'', without the quotes for either of them. (It is a good idea
to create a variable to hold the answer and call it \$answer, or some other
reasonably standard name. Do not try to compute the answer in the \textbf{Answer}
field itself; it will not work as you expect.) Now save the problem and \textbf{View}
it. You'll see a randomized problem.

For each student, the same random number will be used each time they visit
the problem, but each student will get different random numbers. For any
but the simplest random problems, you'll want to see several random problems
to make sure everything is working out correctly. This is what the \textbf{Random
Seed\index{Random Seed}} field is for. To see another randomized version
of the problem you've just created, put another number into the \textbf{Random
Seed} field and hit \textbf{Change}. It doesn't really matter what number
you put into the field. But for any given \textbf{Random Seed} with the same
problem, you'll see the same randomized problem generated for you. (If you
change the \textbf{Script}, you are no longer guaranteed to get the same
problem.) 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>