# This is a comment in Python
print("Hello, World!")
Hello, World!
Programming: Everyday Decision-Making Algorithms
. . .
We really appreciate active participation and interaction!
. . .
No worries, we will help you out if you have any questions!
. . .
This is just in order to provide you with working solutions after each deadline.
We will mostly not cover Python during the lectures!
. . .
Question: Anybody know why?
. . .
. . .
Don’t worry, we will help you out if you have any questions!
We are convinced that this course will be quite interesting and teach you more for your daily life than most other courses!
. . .
But you should not simply use them to replace your learning.
. . .
Great resources to start are books and small challenges. You can find a list of book recommendations at the end of the lecture. Small challenges to solve can for example be found on Codewars.
. . .
IDE = Integrated Development Environment
. . .
If the installation does not work, let us know!
. . .
Unsure on how to work with VS Code and notebooks? Take a look at the tutorial from VS Code and/or ask us! We are happy to help you out!
. . .
Not all packages available in Python are available here, thus you might need a computer to solve certain problems. For our course, this should not be a problem.
Task: Create a directory for the course and create a new file called hello_world.py
with the following code:
# This is a comment in Python
print("Hello, World!")
Hello, World!
. . .
Run it with the green ‘run’ button or by pressing F5!
. . .
“Hello world” is a classic example to start with. Often used as a test to check if your computer is working properly and that you have installed the necessary software.
Question: Anybody know what optimal stopping is?
. . .
The name is a bit misleading, as the problem is not about hiring a secretary, but about finding the best candidate. It comes from the 1960s and thus a little outdated.
n
candidates. . .
Question: Anybody know what ordinal ranking is?
Question: Anybody an idea how we can fail?
. . .
The optimal strategy is to:
. . .
Question: Anybody see a pattern?
n/e
3e
is the base of the natural logarithm (≈ 2.718). . .
import math
= 1/math.e
percentage print(f"Percentage of options to look at: {percentage:.3f}%")
= 20
candidates = candidates/math.e
lookout_phase print(f"Look at first {lookout_phase:.3f} candidates")
Percentage of options to look at: 0.368%
Look at first 7.358 candidates
. . .
No worries if you don’t understand the code! We are essentialy just using the formula to calculate the percentage of candidates to look at.
Let’s visualize the success of a simulation with 20 candidates:
Question: Imagine a dating scenario, where the other person can also reject you. Optimal stopping point?
What if we don’t have a fixed number of candidates, but rather a fixed amount of time?
. . .
. . .
Question: How should we behave?
. . .
. . .
Side note for drivers: An increase in occupancy from 90 to 95% doubles the search time for all drivers!
Question: Can you imagine a scenario where it would be unwise to use optimal stopping?
. . .
That’s it for todays lecture!
We now have covered a brief introduction into optimal stopping and seen how to set up Python. Now we can start with the tutorials!
. . .
Think Python is a great book to start with. It’s available online for free. Schrödinger Programmiert Python is a great alternative for German students, as it is a very playful introduction to programming with lots of examples.
For more interesting literature, take a look at the literature list of this course.
Christian, B., & Griffiths, T. (2016). Algorithms to live by: the computer science of human decisions. First international edition. New York, Henry Holt and Company.↩︎
Large number of candidates! With a small number of candidates, we can do even better.↩︎
This is a bit more advanced. We will not go into the details of the math here and focus more on the insights. For more details see Ferguson, T.S. (1989) ‘Who solved the secretary problem?’, Statistical Science, 4(3). doi:10.1214/ss/1177012493.↩︎
The main inspiration for this lecture. Nils and I have read it and discussed it in depth, always wanting to translate it into a course.↩︎