1 / 76

Nelson Series Talk

On Robots, Probability, and Artificial Intelligence. Nelson Series Talk. Wed, 10/13 7:00 pm HMC’s Galileo Auditorium.

carmelitap
Download Presentation

Nelson Series Talk

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. On Robots, Probability, and Artificial Intelligence Nelson Series Talk Wed, 10/13 7:00 pm HMC’s Galileo Auditorium This talk will expose the audience to recent developments in real-world robotics. The speaker and his team have developed mobile robots that have operated as interactive tour-guides in a Smithsonian museum, assisted elderly people in everyday tasks, and explored several abandoned coal mines inaccessible to people, all completely autonomously. His current effort aims at winning the DARPA Grand Challenge, which requires the development of a ground vehicle that can drive from L.A. to Las Vegas without human assistance. These developments would not have been possible without a new paradigm in robot software design, known as probabilistic robotics. Probabilistic robotics imports concepts from statistics and decision theory into the field of robotics. As part of this presentation, the speaker will introduce the audience to the basics of probabilistic robotics, and explain why statistical techniques have become such an essential tool in robotics, in such a remarkably short time. Sebastian Thrun & robots, Stanford

  2. Last Names Week 7 in CS 5 LAB: A-M • Showcasing unusual solutions… There is no lecture next week! There is no recitation this Friday! There WILL BE recitation NEXT Friday (8 am) • Fall break Seasons by Mike Maguire • Getting data together -- arrays ! due Sunday, 10/24 at midnight M/T sections • HW 8 (2 problems) due Monday, 10/25 at midnight W/Th sections

  3. Syllable counting public static int numSyllables(String w) { int numSyls = 0; int L = w.length(); if ( isVowel(w.charAt(0)) ) // an initial vowel ? ++numSyls; for (int i=1 ; i < L ; ++i) { // vowel preceded by a consonant if ( isVowel(w.charAt(i)) && !isVowel(w.charAt(i-1)) ) ++numSyls; } // final ‘e’ preceded by a consonant if ( w.charAt(L-1) == 'e’ && L >= 2 && !isVowel(w.charAt(L-2)) ) --numSyls; if (numSyls < 1) // every word has at least 1 syllable numSyls = 1; return numSyls; }

  4. A puzzle... How could you print a String backwards? String w = H.nw(); for ( int i= ; ; ) { } How could you print 5 Strings in backwards order? (Not reversing each string…)

  5. A puzzle... How could you print 5 Strings in backwards order? (Not reversing each string…) String s1 = H.nw(); String s2 = H.nw(); String s3 = H.nw(); String s4 = H.nw(); String s5 = H.nw(); H.pl( s5 ); H.pl( s4 ); H.pl( s3 ); H.pl( s2 ); H.pl( s1 ); Not a very flexible solution...

  6. Sentence palindromes Fall leaves after leaves fall Bores are people that say that people are bores First Ladies rule the state and state the rule, “Ladies First!” You can cage a swallow, can’t you, but you can’t swallow a cage, can you? Maybe we don’t even need to solve it?!

  7. A palindromic poem... Seasons by Mike Maguire

  8. Arrays in pictures H.out.println(“Type the number of words: ”); int L = H.ni(); String[] A; A = new String[L]; for (int i=0 ; i<L ; ++i) { A[i] = H.nw(); } for (int i=L-1 ; i>=0 ; --i) { H.pl( A[i] ); }

  9. Arrays in pictures 5 H.out.println(“Type the number of words: ”); int L = H.ni(); String[] A; A = new String[L]; for (int i=0 ; i<L ; ++i) { A[i] = H.nw(); } for (int i=L-1 ; i>=0 ; --i) { H.pl( A[i] ); } int L

  10. Arrays in pictures 5 H.out.println(“Type the number of words: ”); int L = H.ni(); String[] A; A = new String[L]; for (int i=0 ; i<L ; ++i) { A[i] = H.nw(); } for (int i=L-1 ; i>=0 ; --i) { H.pl( A[i] ); } int L String[] A

  11. Arrays in pictures 5 H.out.println(“Type the number of words: ”); int L = H.ni(); String[] A; A = new String[L]; for (int i=0 ; i<L ; ++i) { A[i] = H.nw(); } for (int i=L-1 ; i>=0 ; --i) { H.pl( A[i] ); } int L array reference A[1] A[3] A[0] A[2] A[4] String[] A

  12. Arrays in pictures 5 H.out.println(“Type the number of words: ”); int L = H.ni(); String[] A; A = new String[L]; for (int i=0 ; i<L ; ++i) { A[i] = H.nw(); } for (int i=L-1 ; i>=0 ; --i) { H.pl( A[i] ); } int L A[1] A[3] A[0] A[2] A[4] saw the sigh- I -ign String[] A i is 0 i is 2 i is 4 i is 3 i is 1

  13. Arrays in pictures 5 H.out.println(“Type the number of words: ”); int L = H.ni(); String[] A; A = new String[L]; for (int i=0 ; i<L ; ++i) { A[i] = H.nw(); } for (int i=L-1 ; i>=0 ; --i) { H.pl( A[i] ); } int L A[1] A[3] A[0] A[2] A[4] sigh- saw the I -ign String[] A i is 4 i is 3 i is 1 i is 0 i is 2 -ign sigh- the saw I

  14. Arrays - lists of data items declares a doublearray named A double[] A; declares five doubles named A[0] … A[4] A = new double[5]; length for (int i=0 ; i<5 ; ++i) { A[i] = H.nd(); } loops through the array, getting input from the user index

  15. Arrays in code H.pl(“How many doubles would you like to store? ”); int L = H.ni(); double[] A; A = new double[L]; for (int i=0 ; i<L ; ++i) { A[i] = H.nd(); } // now print them out (in forward order !)

  16. James Gosling • Software architect for Sun Microsystems • Primary designer of the Java programming language • Sees Bill Gates as a dangerous force…

  17. Strings Arrays vs double, int, String, boolean, char, (any type!) char Element types double[] A; A = new double[100]; Example Declaration String s; A[i] s.charAt(i) The ith element A.length s.length() Length Range from 0 up to length-1 Be careful not to go out of bounds! Warning java.lang.StringIndexOutOfBoundsException: -1 java.lang.ArrayIndexOutOfBoundsException: -1

  18. T. T. Securities Input stock prices for a number of days in a row, and then analyze that data… .

  19. T. T. Securities Input stock prices for a number of days in a row, and then analyze that data… . Menu Software 0 Display prices 1 Sum of prices 2 Average of prices 3 St. dev. of prices 4 Minimum price 5 Index of minimum price 6 Maximum price 7 Index of minimum price 8 Your TTS investment strategy 9 Quit Which choice would you like?

  20. T. T. Securities Input stock prices for a number of days in a row, and then analyze that data… . Menu Software 0 Display prices 1 Sum of prices 2 Average of prices 3 St. dev. of prices 4 Minimum price 5 Index of minimum price 6 Maximum price 7 Index of minimum price 8 Your TTS investment strategy 9 Quit Which choice would you like? Hardware

  21. T. T. Securities Input stock prices for a number of days in a row, and then analyze that data… . methods Menu void menu() void prices(double[] A) double sum(double[] A) double average(double[] A) double stdev(double[] A) double min(double[] A) int minIndex(double[] A) double max(double[] A) int maxIndex(double[] A) no separate method needed 0 Display prices 1 Sum of prices 2 Average of prices 3 St. dev. of prices 4 Minimum price 5 Index of minimum price 6 Maximum price 7 Index of minimum price 8 Your TTS investment strategy 9 Quit Which choice would you like? …

  22. Standard Deviation There are a number of formulas, but we will use this one: methods Menu double stdev(double[] A) 0 Display prices 1 Sum of prices 2 Average of prices 3 St. dev. of prices 4 Minimum price 5 Index of minimum price 6 Maximum price 7 Index of minimum price 8 Your TTS investment strategy 9 Quit Which choice would you like?  (A[i] - Aav)2 i L - 1

  23. Code Sketch: main public staticvoid main(String[] args) { H.pl(“How many days?”); int L = H.ni(); // get array length double[] A = new double[L]; // create array A H.pl(“Please input your prices:”); for (int i=0 ; i<L ; ++i) { A[i] = H.nd(); } while (true) { // print menu and handle choices

  24. Printing the prices public static void prices(double[] A)

  25. “Quiz” Finish these two methods… • This method returns the sum of the elements in the input array. public static double sum(double[] A) { double s = 0.0; for ( { } return s; } • This method returns the average of the elements in the input array. public static double average(double[] A) “Extra Credit”: How concise can this method be?

  26. This method returns the maximum element from the input array. public static double max(double[] A) Extra: What is something unusual and unrelated to CS 5 that you & the person next to you have in common ?!

  27. Using sum public static void main(String[] args) { // set up the array A of stock prices H.pl( “The sum is ” + sum(A) ); } 90.0 5.0 60.0 42.0 75.0 10.0 double[] A public static double sum(double[] Z) { // see previous page or quiz … return ans; } double[] Z

  28. Using sum public static void main(String[] args) { // set up the array A of stock prices H.pl( “The sum is ” + sum(A) ); } 90.0 5.0 60.0 42.0 75.0 10.0 double[] A 2 references to the same list of data public static double sum(double[] Z) { // see previous page or quiz … return ans; } double[] Z

  29. Array Searching public static double max (double[] A)

  30. Option #8 Find the most profitable strategy for buying and selling the stock among the prices in the array... Day 0 Price 90.0 Day 1 Price 10.0 Day 2 Price 60.0 Day 3 Price 42.0 Day 4 Price 75.0 Day 5 Price 5.0

  31. Lights Out ! Hw8 Pr2 Pair Program on on off off off on A starting row of lights 2 5 0 1 3 4 Each turn, a light is selected -- It and its neighbors switch states. 2 is selected 2 5 0 1 3 4 2 5 0 1 3 4 Goal: get all the lights off…

  32. Lights Out Strategy ... // choose HOW you’ll represent the lights ! // let the user set the # of lights from 3 to 15 // start each light randomly on or off // draw the current set of lights // allow the user to select a light // only allow valid lights ! // update the set of lights and repeat

  33. Lights Out ! // draw the current set of lights lights should be separated with vertical bars 2 5 0 1 3 4 “on” lights should be 4x4 blocks of stars | |****|****|****| |****| | |****|****|****| |****| | |****|****|****| |****| | |****|****|****| |****| 0 1 2 3 4 5 6 7 “off” lights should be 4x4 blocks of spaces may display all light numbers up to 15 print light numbers close to the center of each light

  34. Lights Out ! // allow the user to select a light // only allow valid lights !

  35. Lights Out Methods You need to choose your own methods to write for this program... Feel free to use (or ignore) my two methods -- public static void printLights(int[] Lts) public static boolean allAreOff(int[] Lts)

  36. Summary To declare an array: double[] A; String[] song; int[] Lights; To declare an array’s individual elements: A = new double[L]; quip = new String[nWords]; Lights = new int[42]; To loop through an array: for (int i=0 ; i<A.length ; ++i) { do something with A[i] in here ... }

  37. 2 5 0 4 1 3 Lab this week Last Names A-M • Problem 1: T. T. Securities void menu() void prices(double[] A) double sum(double[] A) double average(double[] A) double stdev(double[] A) double min(double[] A) int minIndex(double[] A) double max(double[] A) int maxIndex(double[] A) You’ll need to write (and use) • Problem 2: Lights Out! You may choose what methods to write... | |****|****|****| |****| | |****|****|****| |****| | |****|****|****| |****| | |****|****|****| |****| 0 1 2 3 4 5 • Extra Credit: (1) An undo feature for Lights Out ... (2) A sound-editing program

  38. A palindromic poem... Seasons by Mike Maguire

  39. Representing Sound physics continuous plot of air pressure vs. time sampling samples taken every ~ 1/11000th of a second quantization Each sample is measured on a loudness scale from 0 to 65,535. (This fits into 2 bytes.) storage These two bytes are called a frame. The frames are ordered in an array of bytes. Thus, the raw audio data is a byte[].

  40. “Quiz” Finish these two methods… • This method returns the sum of the elements in the input array. public static double sum(double[] A) { double s = 0.0; for ( { } return s; } • This method returns the average of the elements in the input array. public static double average(double[] A) “Extra Credit”: How concise can this method be?

  41. This method returns the maximum element from the input array. public static double max(double[] A) Extra: What is something unusual and unrelated to CS 5 that you & the person next to you have in common ?!

  42. “Quiz” Follow this code to determine a partner! public static void main(String[] args) { H.pl(“Enter your number -- see overhead slide! ”); int x = H.ni(); if (x > 16 && x%2 == 0) { H.pl( “Your partner is #” + (48-x)/2 ); } else if ( x > 16 ) { H.pl( “Your partner is #” + (64-x) ); } else { H.pl( “Your partner is #” + 2*(24-x) ); } } Then, find this partner and try writing the two methods on the other side -- use the prices example as a starting point.

  43. Try to write these two methods public static double sum(double[] A) Names: public static double average(double[] A) Extra Credit: What is something unusual and unrelated to CS 5 that you two or you three have in common ?!

  44. Arrays in pictures 5 H.out.println(“Type the number of words: ”); int L = H.ni(); String[] A; A = new String[L]; for (int i=0 ; i<L ; ++i) { A[i] = H.nw(); } for (int i=L-1 ; i>=0 ; --i) { H.pl( A[i] ); } int len A[1] A[3] A[0] A[2] A[4] did I it Oops again String[] A i is 0 i is 2 i is 4 i is 3 i is 1

  45. “Quiz” Follow this code to determine a partner! public static void main(String[] args) { H.pl(“Enter your number -- see overhead slide! ”); int x = H.ni(); if (x > 16 && x%2 == 0) { H.pl( “Your partner is #” + (48-x)/2 ); } else if ( x > 16 ) { H.pl( “Your partner is #” + (64-x) ); } else { H.pl( “Your partner is #” + 2*(24-x) ); } } Then, find this partner and try writing the two methods on the other side -- use the prices example as a starting point.

  46. Drawing room  (A[i] - Aav)2 i L - 1 2 5 0 1 3 4 2 5 0 1 3 4 2 5 0 1 3 4

  47. Printed version following this slide

  48. This week in CS 5 • Putting data together with arrays due Sunday, 10/28 at midnight M/T sections • HW 8 (2 problems) due Monday, 10/29 at midnight W/Th sections Recitation for HW8 will be Friday 10/26 No recitation this Friday, 10/19 -- Reading: Week 7’s online notes • Watch out for code indenting ! if ( isVowel(w.charAt(0)) ) { ++numSyls; }

  49. Arrays - lists of data items String[] quip; - declares a String array named quip String[] quip quip = new String[5]; - declares five Strings named quip[0]…quip[4] quip[1] quip[3] quip[0] quip[2] quip[4] String[] quip after leaves leaves fall fall - looping through the array for (int i=0 ; i<5 ; ++i) { quip[i] = H.in.nextWord(); }

More Related