Lab 4: MatPlotLib and VPython

  • Plot function for vertical percolation in Matplotlib
    • the function is f(p) = 1–(1-p^n)^n
    • plotting multiple figures in different frames code and plotting all graphs in one frame code
  • While loop that loops until something is true.
  • VPython program rand_grid.py:
    • Modify the given source to generate random grids until one is produced that vertically percolates. Use the same procedure to determine whether a grid percolates as in problem 2 of problem set 2. Assume that the blue squares(0) percolate, and the red squares(1) block. You will need to use a Boolean value in the condition of the while loop to determine whether a grid has been found that percolates.

Sample Solution

  • Here is a solution to the in-lab problem.

Audio project

  • review of project
  • start on equal_scale(freq, amp, dur, sampler=sin_sample); it is an example with a function as a parameter and an optional argument. Use sampler function as the sampler function (they will write sin_sample)
 
cs190c/lab4.txt · Last modified: 2008/07/24 12:11 by seh
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki