Example Jobs

From Statistics Cluster
Jump to navigation Jump to search

C example

The Problem and the Code

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[])
{
int i,N,incirc=0;
double x,y,circrad2;

sscanf(argv[1], "%d", &N); // get iteration number from input
srand(time(NULL)); // seed random number generator

circrad2=1.0*RAND_MAX;
circrad2*=circrad2; // Define radius squared

for(i=0;i<N;i++){
x=1.0*rand(); y=1.0*rand(); // get rand. point and
incirc += (x*x+y*y) < circrad2; // check if inside circle
}

printf("pi=%.12f\n",4.0*incirc/N); // display probability
return 0;
}

Preparation for Job Submission

Job Submission and Management

R example

The Problem and the Code

Preparation for Job Submission

Job Submission and Management

Acknowledgement

Examples provided by Igor Senderovich