SlideShare a Scribd company logo
Algorithms to Live By
The Computer Science of Human Decisions
CMPSC-511
Sp2021 2
How Can CS Help Us In Our Lives?
● Based on the namesake book by Brian
Christian and Tom Griffiths
CMPSC-511
Sp2021 3
Optimal Stopping (The 37% Rule)
● The “Secretary Problem”
– Have a list of candidates for a position. Want to choose the best. Do not have
enough resources to interview everyone. When to stop interviewing?
– Formulated in 1960, published in Scientific American
– Take the best applicant after interviewing 37% (1/e) applicants!
● “Lover’s Leap”: at what age to stop dating and start building a
family?
– Have a time range (say, from 18 to 40). The 37% rule: when you are 26 y/o
(37% of 18--40), marry one of those dates!
CMPSC-511
Sp2021 4
Optimal Stopping (cont.)
● When to park?
– Move along an infinitely long street with parking meters towards your
destination
– Get N blocks close to the destination, then take the first available spot
● N is the function of occupancy rate: 1 for 50%, 7 for 90%, 69 for
99%, 693 for 99.9% (this is ridiculous!)
● When to sell?
● When to quit a risky business?
CMPSC-511
Sp2021 5
Exploit/Explore
● Stick to something old (“exploit”) or try something new (“explore”)?
– “Explore” = gather information [e.g., about restaurants], “exploit” = use
information [e.g., re-visit a known restaurant]
● Possible solution: “Win-Stay, Lose-Shift” (1952)
– As long as exploitation pays off, keep exploiting.
– When it does not, try something else.
– Better than random, but not perfect (“shift” in a rush?)
CMPSC-511
Sp2021 6
Exploit/Explore (cont.)
● Better solution: Gittins Index, a combined measure of wins and losses
– Can be tabulated. Consider two restaurants:
● GI1(2 wins, 2 losses)=0.6010
● GI2(0 wins, 0 losses)=0.7029
– Always follow the strategy with the highest Gittins Index:
● Switch to the second restaurant!
● Yet another alternative solution: minimize regret!
– Regret = satisfaction vs. expectation. Can be quantified.
CMPSC-511
Sp2021 7
Caching
● Libraries are an example of memory hierarchy:
– display space at the front (“primary memory”)
– stacks (“secondary memory”)
– offsite storage (“tertiary memory”)
● Where to put returned books?
– To the front! (“Most Recently Used,” if temporal locality holds)
● What do libraries do?
– Put the most recent acquisitions to the front! (FIFO)
– Turn the library inside out!
CMPSC-511
Sp2021 8
Scheduling
● Gantt charts for your task list (1910s)
● How to execute your task list if you have deadlines?
– Earliest Due Date strategy minimizes maximum lateness
● The optimal strategy
– Modification, Moore’s Algorithm: “throw away the biggest item”
● If you cannot do everything by the due date, minimize the number
of unfinished tasks
CMPSC-511
Sp2021 9
Scheduling (cont.)
● Have no deadlines? Minimize the collective outsider’s delay!
– Shortest Processing Time: always do the quickest task. Get things done!
● What if the tasks have priorities/weights?
– Divide each task’s weight by its processing time to get density
– Execute in the order of decreasing densities
● Paying debts
– Want to minimize the payoff? Funnel the money in the debt with the highest
interest rate.
– Want to minimize the number of debts? Pay the smallest debt.
CMPSC-511
Sp2021 10
Scheduling (cont.)
● Preemption
– Execute tasks in small blocks. Reduces fatigue.
– The price of “context switch” from one task to another (attention switch).
● Metawork! (Rather than “real work.”)
● Thrashing
– Preoccupied with metawork?
– Solution: the art of saying “no.”
CMPSC-511
Sp2021 11
Bayesian Predictions
● To make a prediction, we need to know prior probabilities (“given
that ...”)
● Copernican Principle: absent any prior knowledge about a process,
we are likely to be in the middle of it.
– It will take the process the same time terminate as it took to begin.
– “The [near] future is the same as the [near] past.”
● Will a 99-y/o live another 99 years?
CMPSC-511
Sp2021 12
Bayesian Predictions (cont.)
● Power law data (scale free; no average; “rich get
richer”; preferential attachment)
– Multiplicative rule: predict by multiplying by some
constant (x2 for Copernican principle, x1.4 for lifetime
grosses of movies)
● Normal data
– Average rule (predict the average if below the average; add
small constant if above the average)
– A 99-y/o will live to 99+Y years
● Erlang data (distribution of phone call durations)
– Additive rule (predict some constant additional duration)
– “Just five more minutes!”
CMPSC-511
Sp2021 13
Randomness
● Problem: organize a 10-city world vacation with the cheapest air
transportation
– 10! = 3,628,800 variants
● Greedy approach: always fly to the next cheapest destination
– Does not produce globally optimal solution
● Hill climbing: construct a random itinerary, randomly swap pairs of
cities if a swap decreases the cost
– May end up in a local maximum: good locally, bad globally
CMPSC-511
Sp2021 14
Randomness (cont.)
● Hill climbing with jitter: climb the hill but also randomly accept
results that make the outcome worse
● Hill climbing with restarts: climb the hill many times starting from
different initial random itineraries; continue until no improvement
● Simulated annealing: climb the hill but randomly accept results that
make the outcome worse with the decreasing probability of
acceptance
– Starts as hill climbing with jitter
– Becomes the regular hill climbing at the end
– Best results!

More Related Content

Similar to Algorithms

What to do when detect deadlock
What to do when detect deadlockWhat to do when detect deadlock
What to do when detect deadlock
Syed Zaid Irshad
 
Storm users group real time hadoop
Storm users group real time hadoopStorm users group real time hadoop
Storm users group real time hadoop
Ted Dunning
 
Storm Users Group Real Time Hadoop
Storm Users Group Real Time HadoopStorm Users Group Real Time Hadoop
Storm Users Group Real Time Hadoop
MapR Technologies
 
NoSQL and Einstein's theory of relativity
NoSQL and Einstein's theory of relativityNoSQL and Einstein's theory of relativity
NoSQL and Einstein's theory of relativity
Lars Marius Garshol
 
Automated University Timetabling
Automated University TimetablingAutomated University Timetabling
Automated University Timetabling
Alexandre Pinto
 
Computer network (8)
Computer network (8)Computer network (8)
Computer network (8)
NYversity
 
Operation-Research-Present
Operation-Research-PresentOperation-Research-Present
Operation-Research-Present
rapirent
 
Products go Green: Worst-Case Energy Consumption in Software Product Lines
Products go Green: Worst-Case Energy Consumption in Software Product LinesProducts go Green: Worst-Case Energy Consumption in Software Product Lines
Products go Green: Worst-Case Energy Consumption in Software Product Lines
GreenLabAtDI
 
“TinyML Isn’t Thinking Big Enough,” a Presentation from Perceive
“TinyML Isn’t Thinking Big Enough,” a Presentation from Perceive“TinyML Isn’t Thinking Big Enough,” a Presentation from Perceive
“TinyML Isn’t Thinking Big Enough,” a Presentation from Perceive
Edge AI and Vision Alliance
 
0-introduction.pdf
0-introduction.pdf0-introduction.pdf
0-introduction.pdf
ArafathJazeeb1
 
Peddle the Pedal to the Metal
Peddle the Pedal to the MetalPeddle the Pedal to the Metal
Peddle the Pedal to the Metal
C4Media
 
[D2 COMMUNITY] Spark User Group - 머신러닝 인공지능 기법
[D2 COMMUNITY] Spark User Group - 머신러닝 인공지능 기법[D2 COMMUNITY] Spark User Group - 머신러닝 인공지능 기법
[D2 COMMUNITY] Spark User Group - 머신러닝 인공지능 기법
NAVER D2
 

Similar to Algorithms (12)

What to do when detect deadlock
What to do when detect deadlockWhat to do when detect deadlock
What to do when detect deadlock
 
Storm users group real time hadoop
Storm users group real time hadoopStorm users group real time hadoop
Storm users group real time hadoop
 
Storm Users Group Real Time Hadoop
Storm Users Group Real Time HadoopStorm Users Group Real Time Hadoop
Storm Users Group Real Time Hadoop
 
NoSQL and Einstein's theory of relativity
NoSQL and Einstein's theory of relativityNoSQL and Einstein's theory of relativity
NoSQL and Einstein's theory of relativity
 
Automated University Timetabling
Automated University TimetablingAutomated University Timetabling
Automated University Timetabling
 
Computer network (8)
Computer network (8)Computer network (8)
Computer network (8)
 
Operation-Research-Present
Operation-Research-PresentOperation-Research-Present
Operation-Research-Present
 
Products go Green: Worst-Case Energy Consumption in Software Product Lines
Products go Green: Worst-Case Energy Consumption in Software Product LinesProducts go Green: Worst-Case Energy Consumption in Software Product Lines
Products go Green: Worst-Case Energy Consumption in Software Product Lines
 
“TinyML Isn’t Thinking Big Enough,” a Presentation from Perceive
“TinyML Isn’t Thinking Big Enough,” a Presentation from Perceive“TinyML Isn’t Thinking Big Enough,” a Presentation from Perceive
“TinyML Isn’t Thinking Big Enough,” a Presentation from Perceive
 
0-introduction.pdf
0-introduction.pdf0-introduction.pdf
0-introduction.pdf
 
Peddle the Pedal to the Metal
Peddle the Pedal to the MetalPeddle the Pedal to the Metal
Peddle the Pedal to the Metal
 
[D2 COMMUNITY] Spark User Group - 머신러닝 인공지능 기법
[D2 COMMUNITY] Spark User Group - 머신러닝 인공지능 기법[D2 COMMUNITY] Spark User Group - 머신러닝 인공지능 기법
[D2 COMMUNITY] Spark User Group - 머신러닝 인공지능 기법
 

More from Dmitry Zinoviev

Machine Learning Basics for Dummies (no math!)
Machine Learning Basics for Dummies (no math!)Machine Learning Basics for Dummies (no math!)
Machine Learning Basics for Dummies (no math!)
Dmitry Zinoviev
 
WHat is star discourse in post-Soviet film journals?
WHat is star discourse in post-Soviet film journals?WHat is star discourse in post-Soviet film journals?
WHat is star discourse in post-Soviet film journals?
Dmitry Zinoviev
 
The “Musk” Effect at Twitter
The “Musk” Effect at TwitterThe “Musk” Effect at Twitter
The “Musk” Effect at Twitter
Dmitry Zinoviev
 
Are Twitter Networks of Regional Entrepreneurs Gendered?
Are Twitter Networks of Regional Entrepreneurs Gendered?Are Twitter Networks of Regional Entrepreneurs Gendered?
Are Twitter Networks of Regional Entrepreneurs Gendered?
Dmitry Zinoviev
 
Using Complex Network Analysis for Periodization
Using Complex Network Analysis for PeriodizationUsing Complex Network Analysis for Periodization
Using Complex Network Analysis for Periodization
Dmitry Zinoviev
 
Text analysis of The Book Club Play
Text analysis of The Book Club PlayText analysis of The Book Club Play
Text analysis of The Book Club Play
Dmitry Zinoviev
 
Exploring the History of Mental Stigma
Exploring the History of Mental StigmaExploring the History of Mental Stigma
Exploring the History of Mental Stigma
Dmitry Zinoviev
 
Roles and Words in a massive NSSI-Related Interaction Network
Roles and Words in a massive NSSI-Related Interaction NetworkRoles and Words in a massive NSSI-Related Interaction Network
Roles and Words in a massive NSSI-Related Interaction Network
Dmitry Zinoviev
 
“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...
“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...
“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...
Dmitry Zinoviev
 
Network analysis of the 2016 USA presidential campaign tweets
Network analysis of the 2016 USA presidential campaign tweetsNetwork analysis of the 2016 USA presidential campaign tweets
Network analysis of the 2016 USA presidential campaign tweets
Dmitry Zinoviev
 
Network Analysis of The Shining
Network Analysis of The ShiningNetwork Analysis of The Shining
Network Analysis of The Shining
Dmitry Zinoviev
 
The Lord of the Ring. A Network Analysis
The Lord of the Ring. A Network AnalysisThe Lord of the Ring. A Network Analysis
The Lord of the Ring. A Network Analysis
Dmitry Zinoviev
 
Pickling and CSV
Pickling and CSVPickling and CSV
Pickling and CSV
Dmitry Zinoviev
 
Python overview
Python overviewPython overview
Python overview
Dmitry Zinoviev
 
Welcome to CS310!
Welcome to CS310!Welcome to CS310!
Welcome to CS310!
Dmitry Zinoviev
 
Programming languages
Programming languagesProgramming languages
Programming languages
Dmitry Zinoviev
 
The P4 of Networkacy
The P4 of NetworkacyThe P4 of Networkacy
The P4 of Networkacy
Dmitry Zinoviev
 
DaVinci Code. Network Analysis
DaVinci Code. Network AnalysisDaVinci Code. Network Analysis
DaVinci Code. Network Analysis
Dmitry Zinoviev
 
Soviet Popular Music Landscape: Community Structure and Success Predictors
Soviet Popular Music Landscape: Community Structure and Success PredictorsSoviet Popular Music Landscape: Community Structure and Success Predictors
Soviet Popular Music Landscape: Community Structure and Success Predictors
Dmitry Zinoviev
 
C for Java programmers (part 2)
C for Java programmers (part 2)C for Java programmers (part 2)
C for Java programmers (part 2)
Dmitry Zinoviev
 

More from Dmitry Zinoviev (20)

Machine Learning Basics for Dummies (no math!)
Machine Learning Basics for Dummies (no math!)Machine Learning Basics for Dummies (no math!)
Machine Learning Basics for Dummies (no math!)
 
WHat is star discourse in post-Soviet film journals?
WHat is star discourse in post-Soviet film journals?WHat is star discourse in post-Soviet film journals?
WHat is star discourse in post-Soviet film journals?
 
The “Musk” Effect at Twitter
The “Musk” Effect at TwitterThe “Musk” Effect at Twitter
The “Musk” Effect at Twitter
 
Are Twitter Networks of Regional Entrepreneurs Gendered?
Are Twitter Networks of Regional Entrepreneurs Gendered?Are Twitter Networks of Regional Entrepreneurs Gendered?
Are Twitter Networks of Regional Entrepreneurs Gendered?
 
Using Complex Network Analysis for Periodization
Using Complex Network Analysis for PeriodizationUsing Complex Network Analysis for Periodization
Using Complex Network Analysis for Periodization
 
Text analysis of The Book Club Play
Text analysis of The Book Club PlayText analysis of The Book Club Play
Text analysis of The Book Club Play
 
Exploring the History of Mental Stigma
Exploring the History of Mental StigmaExploring the History of Mental Stigma
Exploring the History of Mental Stigma
 
Roles and Words in a massive NSSI-Related Interaction Network
Roles and Words in a massive NSSI-Related Interaction NetworkRoles and Words in a massive NSSI-Related Interaction Network
Roles and Words in a massive NSSI-Related Interaction Network
 
“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...
“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...
“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...
 
Network analysis of the 2016 USA presidential campaign tweets
Network analysis of the 2016 USA presidential campaign tweetsNetwork analysis of the 2016 USA presidential campaign tweets
Network analysis of the 2016 USA presidential campaign tweets
 
Network Analysis of The Shining
Network Analysis of The ShiningNetwork Analysis of The Shining
Network Analysis of The Shining
 
The Lord of the Ring. A Network Analysis
The Lord of the Ring. A Network AnalysisThe Lord of the Ring. A Network Analysis
The Lord of the Ring. A Network Analysis
 
Pickling and CSV
Pickling and CSVPickling and CSV
Pickling and CSV
 
Python overview
Python overviewPython overview
Python overview
 
Welcome to CS310!
Welcome to CS310!Welcome to CS310!
Welcome to CS310!
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
The P4 of Networkacy
The P4 of NetworkacyThe P4 of Networkacy
The P4 of Networkacy
 
DaVinci Code. Network Analysis
DaVinci Code. Network AnalysisDaVinci Code. Network Analysis
DaVinci Code. Network Analysis
 
Soviet Popular Music Landscape: Community Structure and Success Predictors
Soviet Popular Music Landscape: Community Structure and Success PredictorsSoviet Popular Music Landscape: Community Structure and Success Predictors
Soviet Popular Music Landscape: Community Structure and Success Predictors
 
C for Java programmers (part 2)
C for Java programmers (part 2)C for Java programmers (part 2)
C for Java programmers (part 2)
 

Recently uploaded

Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
abdulrafaychaudhry
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
vrstrong314
 

Recently uploaded (20)

Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
 

Algorithms

  • 1. Algorithms to Live By The Computer Science of Human Decisions
  • 2. CMPSC-511 Sp2021 2 How Can CS Help Us In Our Lives? ● Based on the namesake book by Brian Christian and Tom Griffiths
  • 3. CMPSC-511 Sp2021 3 Optimal Stopping (The 37% Rule) ● The “Secretary Problem” – Have a list of candidates for a position. Want to choose the best. Do not have enough resources to interview everyone. When to stop interviewing? – Formulated in 1960, published in Scientific American – Take the best applicant after interviewing 37% (1/e) applicants! ● “Lover’s Leap”: at what age to stop dating and start building a family? – Have a time range (say, from 18 to 40). The 37% rule: when you are 26 y/o (37% of 18--40), marry one of those dates!
  • 4. CMPSC-511 Sp2021 4 Optimal Stopping (cont.) ● When to park? – Move along an infinitely long street with parking meters towards your destination – Get N blocks close to the destination, then take the first available spot ● N is the function of occupancy rate: 1 for 50%, 7 for 90%, 69 for 99%, 693 for 99.9% (this is ridiculous!) ● When to sell? ● When to quit a risky business?
  • 5. CMPSC-511 Sp2021 5 Exploit/Explore ● Stick to something old (“exploit”) or try something new (“explore”)? – “Explore” = gather information [e.g., about restaurants], “exploit” = use information [e.g., re-visit a known restaurant] ● Possible solution: “Win-Stay, Lose-Shift” (1952) – As long as exploitation pays off, keep exploiting. – When it does not, try something else. – Better than random, but not perfect (“shift” in a rush?)
  • 6. CMPSC-511 Sp2021 6 Exploit/Explore (cont.) ● Better solution: Gittins Index, a combined measure of wins and losses – Can be tabulated. Consider two restaurants: ● GI1(2 wins, 2 losses)=0.6010 ● GI2(0 wins, 0 losses)=0.7029 – Always follow the strategy with the highest Gittins Index: ● Switch to the second restaurant! ● Yet another alternative solution: minimize regret! – Regret = satisfaction vs. expectation. Can be quantified.
  • 7. CMPSC-511 Sp2021 7 Caching ● Libraries are an example of memory hierarchy: – display space at the front (“primary memory”) – stacks (“secondary memory”) – offsite storage (“tertiary memory”) ● Where to put returned books? – To the front! (“Most Recently Used,” if temporal locality holds) ● What do libraries do? – Put the most recent acquisitions to the front! (FIFO) – Turn the library inside out!
  • 8. CMPSC-511 Sp2021 8 Scheduling ● Gantt charts for your task list (1910s) ● How to execute your task list if you have deadlines? – Earliest Due Date strategy minimizes maximum lateness ● The optimal strategy – Modification, Moore’s Algorithm: “throw away the biggest item” ● If you cannot do everything by the due date, minimize the number of unfinished tasks
  • 9. CMPSC-511 Sp2021 9 Scheduling (cont.) ● Have no deadlines? Minimize the collective outsider’s delay! – Shortest Processing Time: always do the quickest task. Get things done! ● What if the tasks have priorities/weights? – Divide each task’s weight by its processing time to get density – Execute in the order of decreasing densities ● Paying debts – Want to minimize the payoff? Funnel the money in the debt with the highest interest rate. – Want to minimize the number of debts? Pay the smallest debt.
  • 10. CMPSC-511 Sp2021 10 Scheduling (cont.) ● Preemption – Execute tasks in small blocks. Reduces fatigue. – The price of “context switch” from one task to another (attention switch). ● Metawork! (Rather than “real work.”) ● Thrashing – Preoccupied with metawork? – Solution: the art of saying “no.”
  • 11. CMPSC-511 Sp2021 11 Bayesian Predictions ● To make a prediction, we need to know prior probabilities (“given that ...”) ● Copernican Principle: absent any prior knowledge about a process, we are likely to be in the middle of it. – It will take the process the same time terminate as it took to begin. – “The [near] future is the same as the [near] past.” ● Will a 99-y/o live another 99 years?
  • 12. CMPSC-511 Sp2021 12 Bayesian Predictions (cont.) ● Power law data (scale free; no average; “rich get richer”; preferential attachment) – Multiplicative rule: predict by multiplying by some constant (x2 for Copernican principle, x1.4 for lifetime grosses of movies) ● Normal data – Average rule (predict the average if below the average; add small constant if above the average) – A 99-y/o will live to 99+Y years ● Erlang data (distribution of phone call durations) – Additive rule (predict some constant additional duration) – “Just five more minutes!”
  • 13. CMPSC-511 Sp2021 13 Randomness ● Problem: organize a 10-city world vacation with the cheapest air transportation – 10! = 3,628,800 variants ● Greedy approach: always fly to the next cheapest destination – Does not produce globally optimal solution ● Hill climbing: construct a random itinerary, randomly swap pairs of cities if a swap decreases the cost – May end up in a local maximum: good locally, bad globally
  • 14. CMPSC-511 Sp2021 14 Randomness (cont.) ● Hill climbing with jitter: climb the hill but also randomly accept results that make the outcome worse ● Hill climbing with restarts: climb the hill many times starting from different initial random itineraries; continue until no improvement ● Simulated annealing: climb the hill but randomly accept results that make the outcome worse with the decreasing probability of acceptance – Starts as hill climbing with jitter – Becomes the regular hill climbing at the end – Best results!