Tscope5
randomizer02.c
////////////////////////////////////////////////////////////////////////////////
//
// __ ______
// / /_______________ ____ ___ / ____/
// / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
// / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
// \__/____/\___/\____/ .___/\___/ /_____/
// /_/
//
// randomizer02.c
// - Draw 10 random doubles from a uniform distribution.
// - Draw 10 random doubles from a normal distribution.
// - Draw 10 random doubles from an exponential distribution.
////////////////////////////////////////////////////////////////////////////////
#include <tscope5.h>
int main()
{
// open the display
ts5_set_coordinate_system(TS5_DISPLAY_COORDINATES);
ts5_set_text_alignment(TS5_ALIGN_LEFT);
// draw from a uniform distribution
int i;
double diff=0;
ts5_printf(20.0, 20.0, "10 random doubles from a uniform distribution: ");
for (i=0; i<10; i++) {
diff += ts5_printf(20.0+diff, 40.0, "%3.2f ", ts5_random_uniform());
}
// draw from a normal distribution
diff=0;
ts5_printf(20.0, 80.0, "10 random doubles from a normal distribution: ");
for (i=0; i<10; i++) {
diff += ts5_printf(20.0+diff, 100.0, "%3.2f ", ts5_random_normal(0.0, 1.0));
}
// draw from an exponential distribution
diff=0;
ts5_printf(20.0, 140.0, "10 random doubles from an exponential distribution: ");
for (i=0; i<10; i++) {
diff += ts5_printf(20.0+diff, 160.0, "%3.2f ", ts5_random_exponential(1.0));
}
// wait for a click
return 0;
}