You are on page 1of 1

CS355: Programming Tools and Techniques Octave and Gnuplot

Assignment Total marks: 40 Q1 (1 + 4 + 1 + 8 + 8 + 5 + 3 = 30)

(i) Using Octave, generate all 101 integers from 0 to 100 into the vector x. (ii) Now, generate the binomial distribution function over the points in x with parameters 100 and 0.3, i.e., for each xi , generate yi = B100,0.3 (xi ). (iii) Output the sum of all the elements of y. (iv) Next, generate samples from the binomial distribution B100,0.3 with parameters 100 and 0.3. Generate four sets of random points whose cardinalities are 102 , 103 , 104 and 105 . (v) Compute histograms h1 to h4 on these four sets: the histogram centers should be the points in x. Normalize the histograms such that they add up to 1. (vi) Plot y along with the histograms h1 to h4 of the four sample sets against x. (vii) Output all the data created into a le in a format suitable for plotting in Gnuplot. For many of these tasks, you may use the doc (especially the Statistics) and help functionalities in Octave. Submit your answer as rollno normal.m and rollno data.dat les where rollno is your roll number. The data le should contain the histograms h1 to h4 in addition to x and y.

Q2

(10)

Using the le that has been plotted in Q1, use Gnuplot to draw a graph that depicts the 5 lines: the perfect binomial distribution function y and the four histograms (which are samples of it). Make sure the graph is complete with labeled axes, title and key. Label the graph with the word mean at the peak of y. Submit your answer as rollno plot.gnu and rollno plot.eps les where rollno is your roll number.

You might also like