Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Pseudo Code Hint for Pi estimation Problem #1 START PROGRAM Set Parameters for Pi estimation (radius, number of dart throws) Set Histogram Parameters • Lower Bound • Upper Bound • Bin Width (pi/100 or pi/1000) Compute Number of bins needed (for the defined range and bin width) • nbins = int ( (Upper Bound – Lower Bound) / Bin Width ) Initialize histogram • Initialize empty list (e.g. histogram = []) • loop over the number of bins and append/initialize to zero ◦ e.g. : for k in range(nbins): histogram.append(0) Define the number of times to loop and compute pi esitmate (e.g. npoints = 100000) LOOP – over npoints Compute Pi estimate – (i.e. the major portion of the starting python code) Test if estimate is between Lower Bound and Upper Bound if yes, then: • compute the relevant bin index for value of pi estimate ◦ index = (value – Lower Bound) / Bind Width • Increment the relevent bin ◦ e.g. : histogram[index] += 1 END LOOP Normalize Histogram • Compute the total bin counts • Normalize by the total ( e.g. histogram[index] = float( histogram[index] ) / float( total ) Output Normalized distribution to a file/screen ( as: bin value vs. normalized distribution value) • Compute the current bin value ◦ e.g. : bin_val = Lower Bound + (Bin Width * float( index ) ) , where index is the current bin index • Output END PROGRAM