The question is in word file attached andthe related program is in

This is a  pascal program so save it in .pas file

 

 

Program TWODHISTOGRAM;

 

{ Author     : VENKAT SRI CHAITYA THOTA

 

  Date       : 11/14/2013

 

  Course Name: CSC 540 Graduate Research Seminar

 

  

  Description: The program illustrates the behavior of the Pascal random number generator by throwing random numbers between 20001 and 380000 (inclusive). In the first part, the results are binned into into 10 equal histogram bins and the bin      

  Frequencies are written into an output file with extension .csv after each simulation run. The .csv file can be directly opened with excel which will be used as a graphing program.

 

  In the second part, the results are binned into 36 equal histogram bins and written into an output .csv file in the form of a 6×6 matrix after each simulation run. The resultant frequencies will then used to plot 2D histogram.

   

  The code is developed in such a way that it takes two runtime inputs from the user so that the same code can be re-used to generate all the required results. The inputs are:

  1. The bins to generate and 

  2. The runs to do  

 

  Output: The output of bin frequencies is displayed in Freq_output.csv which will be stored in the FPC directory.

}

 

{Declaring the variables and their types}

{Note: The number of runs and the width of the bin are declared as longint as they could fall beyond the limit of the integer}

  Var

      numbins : Integer;{To hold the user input-Number of bins}

 numruns : Longint;{To hold the user input-Number of runs}

      binwidth : Longint;{To hold the calculated Width of the Bins based on the user inputs}

 randnumb : Longint;{To hold Random number from ranging from 20001 to 380000}

      loopvar1 : Longint;{Used as a Loop variable} 

      loopvar2 : Longint;{Used as a Loop variable}

      indexval : Longint;{Used as a Loop variable for calculation}  

      quotient : Integer;{Bin to which the random number belongs to – ranges from 1 to numbins}

      count : Array[1..36] of Integer;{Array to store the Bin frequencies for normal histogram}

      binfreq : Array[1..6,1..6] of Integer;{Array to store the Bin frequencies for the 2D histogram}

      output   : Text;{Variable to assign the output file}   

  Begin

 

{Prompt for the user inputs at runtime and read the same: the number of bins to generate and the number of runs}

 

  writeln(‘Enter the number of bins:’);

  readln(numbins);

 

  writeln(‘Enter the number of runs:’);

  readln(numruns);

 

{Simulation for 10 bins}  

 if numbins = 10 then begin

 

{Calculate width of the bin based on the user inputs}

 binwidth := trunc(360000/numbins);

 

{The below code initializes the bin frequencies to zero}

 For loopvar1 := 1 to 36 do begin

    count[loopvar1] := 0;

 End;  {Ends the initialization for loop}

 

{To generate random numbers later in the code}

 randomize;

 

{Running the simulation for numruns}

{Loop for number of runs}

 For loopvar1 := 1 to numruns do begin 

 

  randnumb := random(360000)+ 20001;{Note: random function with an argument ‘a’ creates values from 0 to a-1}

  quotient := (trunc( (randnumb – 20001)/binwidth ))+1;{quotient ranges from 1 to numbins and is the bin to which the random number randnumb belongs to}

  count[quotient] := count[quotient]+1;{Incrementing the frequency of the bin to which randnumb belongs to by 1}

 

 End; { Ends the numruns for loop}

 

{Generating the output file}

 Assign(output,’Frequency_output.CSV’);{Creating an output file with name: Frequency_output.CSV . Please note the output format is .csv which can be directly   imported to Excel and used as the graphing program later}

 Rewrite(output);

 

 For loopvar1 := 1 to numbins do begin {Writing the bin frequencies into the output file}

  Writeln(output, count[loopvar1]);

 End;

 

 Writeln(‘The bin frequencies are displayed in the frequency_output.csv file in the FPC directory’);

 End;{Ends If}

 

{Simulation for 36 bins}

 if numbins = 36 then begin

{Calculate width of the bin based on the user inputs}

 binwidth := trunc(360000/numbins);

 

{The below code initializes the bin frequencies to zero}

 For loopvar1 := 1 to 36 do begin

    count[loopvar1] := 0;

 End;

{To generate random numbers later in the code}

 randomize;

 

{Running the simulation for numruns runs}

{Loop for number of runs}

 For loopvar1 := 1 to numruns do begin

 

  randnumb := random(360000)+ 20001;{Note: random function with an argument ‘a’ creates values from 0 to a-1}

  quotient := (trunc( (randnumb – 20001)/binwidth ))+1;{quotient ranges from 1 to numbins and is the bin to which the random number randnumb belongs to}

  count[quotient] := count[quotient]+1;{Incrementing the frequency of the bin to which randnumb belongs to by 1}

 

 End; { Ends the numruns for loop}

 

{Code for creating the 6×6 Matrix of frequencies for 2D histogram}

 For loopvar1 := 1 to 6 Do Begin

 For loopvar2 := 1 To 6 Do Begin

 indexval:= loopvar2 + (6*(loopvar1-1));

 binfreq[loopvar1,loopvar2]:= count[indexval];{For example: binfreq[1,1] = count[1], binfreq[1,6] = count[6], binfreq[2,1] = count[7], binfreq[2,6] = count[12] and so on}

 End;{End of Inner for loop}

 End; {End of Outer for loop}

 

{Generating the output file}

 Assign(output,’Frequency_output.CSV’);{Creating an output file with name: Frequency_output.csv. Please note the output format is .csv which can be directly   imported to Excel and used as the graphing program later}

 Rewrite(output);

 

 For loopvar1 := 1 to 6 Do Begin {Writing the 6×6 matrix of frequencies into the output file}

  Writeln(output, binfreq[1,loopvar1],’,’,binfreq[2,loopvar1],’,’,binfreq[3,loopvar1],’,’,binfreq[4,loopvar1],’,’,binfreq[5,loopvar1],’,’,binfreq[6,loopvar1]);

 End;

 

 Writeln(‘The bin frequencies are displayed in the freq_output.csv file in the FPC directory’);

 End;{Ends if}

 

Close(output);

Readln;

 

End.

{End of the program}

Order a unique copy of this paper
(550 words)

Approximate price: $22

Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

We value our customers and so we ensure that what we do is 100% original..
With us you are guaranteed of quality work done by our qualified experts.Your information and everything that you do with us is kept completely confidential.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

The Product ordered is guaranteed to be original. Orders are checked by the most advanced anti-plagiarism software in the market to assure that the Product is 100% original. The Company has a zero tolerance policy for plagiarism.

Read more

Free-revision policy

The Free Revision policy is a courtesy service that the Company provides to help ensure Customer’s total satisfaction with the completed Order. To receive free revision the Company requires that the Customer provide the request within fourteen (14) days from the first completion date and within a period of thirty (30) days for dissertations.

Read more

Privacy policy

The Company is committed to protect the privacy of the Customer and it will never resell or share any of Customer’s personal information, including credit card data, with any third party. All the online transactions are processed through the secure and reliable online payment systems.

Read more

Fair-cooperation guarantee

By placing an order with us, you agree to the service we provide. We will endear to do all that it takes to deliver a comprehensive paper as per your requirements. We also count on your cooperation to ensure that we deliver on this mandate.

Read more

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency