[LON-CAPA-users] How to realize a randomly generated downloadable data set?
Gerd Kortemeyer
lon-capa-users@mail.lon-capa.org
Mon, 7 May 2007 15:14:29 -0400
On May 7, 2007, at 2:56 PM, Gerd Kortemeyer wrote:
>
> Would the students web-savvy enough to copy the data out of a
> textarea?
If yes, then the problem below might do the trick. Alternatively, one
could put a piece of JavaScript around the data which provides a "file."
> On May 7, 2007, at 2:45 PM, Peter Riegler wrote:
>>
>>
>> I want my students to do a frequency analysis of a noisy
>> monofrequential signal (by FFT or whatever). What I have in mind
>> is to have a problem where the student is offered a downloadable
>> file together with a single numerical answer field for entering
>> the obtained signal frequency.
>>
>> If I had a static data file I would make a published resource out
>> of it and hardlink it into the problem file. However, I would like
>> to have individual, i.e. random, data files for each student. Is
>> there a way of having dynamic data files as resources?
>>
<problem>
<script type="loncapa/perl">$omega=2*$pi/&random(30,60,1);
$phi=&random(1,2,0.1);
$amp=&random(3,10,1);
for ($t=0;$t<=600;$t++) {
$func=$amp*(sin($omega*$t+$phi)+&random(-0.2,0.2,0.01));
$data.="$t,$func\n";
}</script>
<startouttext />Copy the data below and perform a Fourier
analysis.<br />
<textarea cols="20" rows="10">$data</textarea><br />
What is the angular frequency of the data?<endouttext />
<numericalresponse unit="rad/s" format="3s" answer="$omega">
<responseparam type="tolerance" default="5%" name="tol"
description="Numerical Tolerance" />
<textline readonly="no" />
</numericalresponse>
</problem>