Todd Mytkowicz Kathryn S. McKinley Wikipedia Sensors Big data - - PowerPoint PPT Presentation

todd mytkowicz kathryn s mckinley
SMART_READER_LITE
LIVE PREVIEW

Todd Mytkowicz Kathryn S. McKinley Wikipedia Sensors Big data - - PowerPoint PPT Presentation

Uncertain< T > A First-Order Type for Uncertain Data James Bornholt Supervisor: Steve Blackburn Todd Mytkowicz Kathryn S. McKinley Wikipedia Sensors Big data Sampson et al. Bishop hidden units z M w (1) w (2) MD KM x D y K inputs


slide-1
SLIDE 1

Uncertain<T>

A First-Order Type for Uncertain Data

James Bornholt Supervisor: Steve Blackburn

slide-2
SLIDE 2

Todd Mytkowicz Kathryn S. McKinley

slide-3
SLIDE 3

Sensors Big data Approximate computing

x0 x1 xD z0 z1 zM y1 yK w(1)

MD

w(2)

KM

w(2)

10

hidden units inputs

  • utputs

Machine learning

Wikipedia Sampson et al. Bishop

uncertain data

slide-4
SLIDE 4

discrete type

struct ¡Geocoordinate ¡{ ¡ ¡ ¡ ¡ ¡double ¡Latitude; ¡ ¡ ¡ ¡ ¡double ¡Longitude; ¡ } ¡ ¡ Geocoordinate ¡Loc ¡= ¡GetGPSLocation(); ¡

slide-5
SLIDE 5

uncertain data discrete type + ??? =

slide-6
SLIDE 6

uncertain data discrete type + = who cares?

slide-7
SLIDE 7

uncertain data discrete type + = uncertainty bug

slide-8
SLIDE 8

uncertain data discrete type + = uncertainty bug

errors that occur when applications pretend that uncertain data is certain

slide-9
SLIDE 9

treating estimates as facts

struct ¡Geocoordinate ¡{ ¡ ¡ ¡double ¡Latitude; ¡ ¡ ¡double ¡Longitude; ¡ ¡ ¡ ¡double ¡HorizontalAccuracy; ¡ } ¡

95% of apps ignore accuracy!

slide-10
SLIDE 10

computation compounds error

slide-11
SLIDE 11

computation compounds error

Usain Bolt

slide-12
SLIDE 12

computation compounds error

20 40 60 80 100

Walking speed (km/h) Time

Usain Bolt

slide-13
SLIDE 13

false positives in questions

if ¡(Speed ¡> ¡60) ¡ ¡IssueSpeedingTicket(); ¡

60 km/h s = 75 km/h Speed

30 60 90 120

Speed (km/h)

slide-14
SLIDE 14

uncertainty bugs

Treating estimates as facts Computation compounds error False positives in questions Caused by poor programming language abstractions Uncertainty should not be abstracted away

slide-15
SLIDE 15

related work

Uncertain data

Sensors, measurements, probabilistic models Flexible Simple

Developer computations

slide-16
SLIDE 16

related work

No abstraction Current abstractions Uncertain data

Sensors, measurements, probabilistic models Flexible Simple

Developer computations

slide-17
SLIDE 17

related work

No abstraction Probabilistic programming Current abstractions Uncertain data

Sensors, measurements, probabilistic models Flexible Simple

Developer computations

slide-18
SLIDE 18

probabilistic programming

Reasoning about probabilistic models earthquake ¡= ¡Bernoulli(0.0001) ¡ burglary ¡ ¡ ¡= ¡Bernoulli(0.001) ¡ alarm ¡ ¡ ¡ ¡ ¡ ¡= ¡earthquake ¡or ¡burglary ¡ ¡ if ¡(earthquake) ¡ ¡ ¡phoneWorking ¡= ¡Bernoulli(0.7) ¡ else ¡ ¡ ¡phoneWorking ¡= ¡Bernoulli(0.99) ¡

slide-19
SLIDE 19

inference

earthquake ¡= ¡Bernoulli(0.0001) ¡ burglary ¡ ¡ ¡= ¡Bernoulli(0.001) ¡ alarm ¡ ¡ ¡ ¡ ¡ ¡= ¡earthquake ¡or ¡burglary ¡ if ¡(earthquake) ¡ ¡ ¡phoneWorking ¡= ¡Bernoulli(0.7) ¡ else ¡ ¡ ¡phoneWorking ¡= ¡Bernoulli(0.99) ¡ ¡

  • bserve(alarm=true) ¡

query(phoneWorking) ¡

What is Pr[phoneWorking=v | alarm=True], for each possible value of v (i.e. True and False)?

slide-20
SLIDE 20

inference is expensive

Some paths of execution are very unlikely

  • 50

100 150 100 200 300 400 500

Number of samples Time to query (sec)

Pr[earthquake]

  • 0.01

0.0001

slide-21
SLIDE 21

related work

No abstraction Probabilistic programming Current abstractions Probabilistic data

Sensors, measurements, probabilistic models Flexible Simple

Developer computations

slide-22
SLIDE 22

related work

No abstraction Probabilistic programming Uncertain<T> Current abstractions Probabilistic data

Sensors, measurements, probabilistic models Flexible Simple

Developer computations

slide-23
SLIDE 23

Uncertain<T> is an uncertain type abstraction.

Encapsulates distributions, like prior work. But focuses on an accessible interface. For everyday programmers, Uncertain<T> enables programs that are more concise, expressive, and correct.

slide-24
SLIDE 24

using Uncertain<T>

Identify the distribution Compute with the distribution Ask questions using conditionals Improve the quality of estimates

slide-25
SLIDE 25

identifying the distribution

Many library programmers already know the distribution they need to return!

identify improve compute question

slide-26
SLIDE 26

identifying the distribution

Many library programmers already know the distribution they need to return!

identify improve compute question

“Get the estimated accuracy of this location, in meters. We define accuracy as the radius of 68% confidence. […] In statistical terms, it is assumed that location errors are random with a normal distribution.” —Android

slide-27
SLIDE 27

representing distributions

identify improve compute question Norm(x; µ, σ) = 1 √ 2πσ exp ⇢ −(x − µ)2 2σ2

slide-28
SLIDE 28

representing distributions

Store probability density functions? Two problems:

  • 1. Even simple operations are complex:
  • 2. Many interesting distributions don’t have PDFs

identify improve compute question Norm(x; µ, σ) = 1 √ 2πσ exp ⇢ −(x − µ)2 2σ2

  • fX+Y (z) =

Z ∞

−∞

fY (z − x)fX(x) dx

slide-29
SLIDE 29

representing distributions

Store probability density functions? Two problems:

  • 1. Even simple operations are complex:
  • 2. Many interesting distributions don’t have PDFs

identify improve compute question Norm(x; µ, σ) = 1 √ 2πσ exp ⇢ −(x − µ)2 2σ2

  • fX+Y (z) =

Z ∞

−∞

fY (z − x)fX(x) dx

slide-30
SLIDE 30

representing distributions

Random sampling: two birds with one stone

Simple operations are simple (e.g., +) More distributions can be represented

Later: how to implement random sampling

identify improve compute question

slide-31
SLIDE 31

computing with distributions

Propagating uncertainty through calculations automatically with operator overloading A key advantage of random sampling: computation is simply* lifting of the original operators

identify improve compute question

slide-32
SLIDE 32

computing with distributions

Propagating uncertainty through calculations automatically with operator overloading A key advantage of random sampling: computation is simply* lifting of the original operators

identify improve compute question

X Y X+Y

a sample of X a sample of Y a sample of X+Y If and then x y x+y

slide-33
SLIDE 33

computing with distributions

* The caveat is that this only works if the operands are independent If not, we need to know something about how the variables are related This is an issue for all probabilistic programming

identify improve compute question

slide-34
SLIDE 34

induced dependencies

identify improve compute question

A ¡= ¡X ¡+ ¡Y ¡ B ¡= ¡A ¡+ ¡X ¡

(X,Y independent)

slide-35
SLIDE 35

induced dependencies

We can distinguish inherent dependencies from programmer-induced dependencies When evaluating B, both operands depend on X, so they are not independent Lazy evaluation to the rescue!

identify improve compute question

A ¡= ¡X ¡+ ¡Y ¡ B ¡= ¡A ¡+ ¡X ¡

(X,Y independent)

slide-36
SLIDE 36

induced dependencies

We can distinguish inherent dependencies from programmer-induced dependencies When evaluating B, both operands depend on X, so they are not independent Lazy evaluation to the rescue!

identify improve compute question

A ¡= ¡X ¡+ ¡Y ¡ B ¡= ¡A ¡+ ¡X ¡

(X,Y independent)

slide-37
SLIDE 37

asking questions

identify improve compute question if ¡(Speed ¡> ¡60) ¡ ¡IssueSpeedingTicket(); ¡

60 km/h s = 75 km/h Speed

30 60 90 120

Speed (km/h)

slide-38
SLIDE 38

comparing means

identify improve compute question if ¡(Speed.E() ¡> ¡60) ¡ ¡IssueSpeedingTicket(); ¡

E[Speed] 60 km/h

30 60 90 120

Speed (km/h)

slide-39
SLIDE 39

comparing evidence

identify improve compute question if ¡((Speed ¡> ¡60).E() ¡> ¡0.95) ¡ ¡IssueSpeedingTicket(); ¡

Pr[Speed > 60] 60 km/h

30 60 90 120

Speed (km/h)

slide-40
SLIDE 40

comparing evidence

identify improve compute question if ¡((Speed ¡> ¡60).E() ¡> ¡0.95) ¡ ¡IssueSpeedingTicket(); ¡

Pr[Speed > 60] 60 km/h

30 60 90 120

Speed (km/h)

> is a lifted operator

slide-41
SLIDE 41

comparing evidence

identify improve compute question if ¡((Speed ¡> ¡60).E() ¡> ¡0.95) ¡ ¡IssueSpeedingTicket(); ¡

Pr[Speed > 60] 60 km/h

30 60 90 120

Speed (km/h)

type Uncertain<bool>

slide-42
SLIDE 42

comparing evidence

identify improve compute question if ¡((Speed ¡> ¡60).E() ¡> ¡0.95) ¡ ¡IssueSpeedingTicket(); ¡

Pr[Speed > 60] 60 km/h

30 60 90 120

Speed (km/h)

mean of Uncertain<bool>

slide-43
SLIDE 43

comparing evidence

identify improve compute question if ¡((Speed ¡> ¡60).E() ¡> ¡0.95) ¡ ¡IssueSpeedingTicket(); ¡

Pr[Speed > 60] 60 km/h

30 60 90 120

Speed (km/h)

= number in [0,1]

slide-44
SLIDE 44

comparing evidence

identify improve compute question if ¡((Speed ¡> ¡60).E() ¡> ¡0.95) ¡ ¡IssueSpeedingTicket(); ¡

Pr[Speed > 60] 60 km/h

30 60 90 120

Speed (km/h)

% of True instances

slide-45
SLIDE 45

is there a >95% chance that Speed > 60?

comparing evidence

identify improve compute question if ¡((Speed ¡> ¡60).E() ¡> ¡0.95) ¡ ¡IssueSpeedingTicket(); ¡

Pr[Speed > 60] 60 km/h

30 60 90 120

Speed (km/h)

slide-46
SLIDE 46

comparing evidence

The threshold allows the programmer to balance false positives and false negatives Higher thresholds give fewer false positives, but more false negatives

identify improve compute question if ¡((Speed ¡> ¡60).E() ¡> ¡0.95) ¡ ¡IssueSpeedingTicket(); ¡

slide-47
SLIDE 47

improving estimates

identify improve compute question

Uncertain<T> is Bayesian: error distributions track degrees of belief about the value of a variable Bayes’ theorem: use prior knowledge to improve estimates

Pr[H|E] = Pr[E|H] Pr[H] Pr[E]

slide-48
SLIDE 48

improving estimates

identify improve compute question

Pr[H|E] = Pr[E|H] Pr[H] Pr[E]

slide-49
SLIDE 49

improving estimates

identify improve compute question

Pr[H|E] = Pr[E|H] Pr[H] Pr[E]

likelihood

E[Location]

0.00 0.05 0.10 0.15 0.20 0.25

Location Density

Likelihood

slide-50
SLIDE 50

improving estimates

identify improve compute question

Pr[H|E] = Pr[E|H] Pr[H] Pr[E]

likelihood prior

E[Location]

0.00 0.05 0.10 0.15 0.20 0.25

Location Density

Prior Likelihood

slide-51
SLIDE 51

improving estimates

identify improve compute question

Pr[H|E] = Pr[E|H] Pr[H] Pr[E]

posterior likelihood prior

E[Location]

0.00 0.05 0.10 0.15 0.20 0.25

Location Density

Prior Likelihood Posterior

slide-52
SLIDE 52

improving estimates

identify improve compute question

Pr[H|E] = Pr[E|H] Pr[H] Pr[E]

posterior likelihood prior

E[Location]

0.00 0.05 0.10 0.15 0.20 0.25

Location Density

Prior Likelihood Posterior

slide-53
SLIDE 53

implementing Uncertain<T>

Two key insights in the design inform an efficient implementation

  • 1. Distributions are random samples

Suggests lazy evaluation

  • 2. All evaluations end up in expected values

Suggests hypothesis tests

slide-54
SLIDE 54

lazy evaluation

Uncertain<T> uses random sampling, but how? Option 1: store a vector of N samples

5.6 2.8 6.4 4.9 4.9 5.1 4.3 5.0 … 4.6

A

slide-55
SLIDE 55

lazy evaluation

Uncertain<T> uses random sampling, but how? Option 1: store a vector of N samples

5.6 2.8 6.4 4.9 4.9 5.1 4.3 5.0 … 4.6 4.0 3.2 1.1 3.5 3.9 3.4 4.7 3.8 … 2.2

A B +

slide-56
SLIDE 56

lazy evaluation

Uncertain<T> uses random sampling, but how? Option 1: store a vector of N samples

5.6 2.8 6.4 4.9 4.9 5.1 4.3 5.0 … 4.6 4.0 3.2 1.1 3.5 3.9 3.4 4.7 3.8 … 2.2 9.6 6.0 7.5 8.4 8.8 8.5 9.0 8.8 … 6.8

A B A+B +

slide-57
SLIDE 57

lazy evaluation

Uncertain<T> uses random sampling, but how? Option 1: store a vector of N samples

5.6 2.8 6.4 4.9 4.9 5.1 4.3 5.0 … 4.6 4.0 3.2 1.1 3.5 3.9 3.4 4.7 3.8 … 2.2 9.6 6.0 7.5 8.4 8.8 8.5 9.0 8.8 … 6.8 + + + + + + + + + +

A B A+B +

slide-58
SLIDE 58

lazy evaluation

Uncertain<T> uses random sampling, but how? Option 1: store a vector of N samples

5.6 2.8 6.4 4.9 4.9 5.1 4.3 5.0 … 4.6 4.0 3.2 1.1 3.5 3.9 3.4 4.7 3.8 … 2.2 9.6 6.0 7.5 8.4 8.8 8.5 9.0 8.8 … 6.8 + + + + + + + + + +

A B A+B +

slide-59
SLIDE 59

lazy evaluation

Uncertain<T> uses random sampling, but how? Option 1: store a vector of N samples

5.6 2.8 6.4 4.9 4.9 5.1 4.3 5.0 … 4.6 4.0 3.2 1.1 3.5 3.9 3.4 4.7 3.8 … 2.2 9.6 6.0 7.5 8.4 8.8 8.5 9.0 8.8 … 6.8 + + + + + + + + + +

A B A+B +

slide-60
SLIDE 60

lazy evaluation

Uncertain<T> uses random sampling, but how? Option 1: store a vector of N samples

5.6 2.8 6.4 4.9 4.9 5.1 4.3 5.0 … 4.6 4.0 3.2 1.1 3.5 3.9 3.4 4.7 3.8 … 2.2 9.6 6.0 7.5 8.4 8.8 8.5 9.0 8.8 … 6.8 + + + + + + + + + +

A B A+B +

slide-61
SLIDE 61

lazy evaluation

Uncertain<T> uses random sampling, but how? Option 1: store a vector of N samples

5.6 2.8 6.4 4.9 4.9 5.1 4.3 5.0 … 4.6 4.0 3.2 1.1 3.5 3.9 3.4 4.7 3.8 … 2.2 9.6 6.0 7.5 8.4 8.8 8.5 9.0 8.8 … 6.8 + + + + + + + + + +

A B A+B +

slide-62
SLIDE 62

lazy evaluation

Uncertain<T> uses random sampling, but how? Option 1: store a vector of N samples

5.6 2.8 6.4 4.9 4.9 5.1 4.3 5.0 … 4.6 4.0 3.2 1.1 3.5 3.9 3.4 4.7 3.8 … 2.2 9.6 6.0 7.5 8.4 8.8 8.5 9.0 8.8 … 6.8 + + + + + + + + + +

A B A+B +

slide-63
SLIDE 63

lazy evaluation

Suppose an oracle tells us the “right” sample size for a particular operation (we’ll invent this oracle shortly!) How do we satisfy this sample size? Uncertain<T> represents distributions with sampling functions, returning a new sample on each invocation Operators combining distributions are lazy, constructing a symbolic expression tree

slide-64
SLIDE 64

evaluating expression trees

A

slide-65
SLIDE 65

evaluating expression trees

A B var ¡A ¡= ¡GetReading() ¡ var ¡B ¡= ¡GetReading() ¡ var ¡Sum ¡= ¡A ¡+ ¡B ¡ if ¡((Sum ¡> ¡10).E() ¡> ¡75%): ¡ ¡ ¡Alert() ¡

slide-66
SLIDE 66

evaluating expression trees

A B + var ¡A ¡= ¡GetReading() ¡ var ¡B ¡= ¡GetReading() ¡ var ¡Sum ¡= ¡A ¡+ ¡B ¡ if ¡((Sum ¡> ¡10).E() ¡> ¡75%): ¡ ¡ ¡Alert() ¡ Sum

slide-67
SLIDE 67

evaluating expression trees

A B + > 10 var ¡A ¡= ¡GetReading() ¡ var ¡B ¡= ¡GetReading() ¡ var ¡Sum ¡= ¡A ¡+ ¡B ¡ if ¡((Sum ¡> ¡10).E() ¡> ¡75%): ¡ ¡ ¡Alert() ¡ Sum Sum > 10

slide-68
SLIDE 68

hypothesis tests

How do we decide the “right” sample size for a particular operation? Distributions only evaluated at conditionals, so use hypothesis tests to address sampling error

slide-69
SLIDE 69

hypothesis tests

This code implicitly performs a hypothesis test Start with a base sample size Continue increasing the sample size until either

  • 1. The null hypothesis is rejected; or
  • 2. A maximum sample size limit is reached (to

ensure termination)

if ¡(Speed.E() ¡> ¡60) ¡ ¡IssueSpeedingTicket(); ¡

slide-70
SLIDE 70

smartphone GPS sensors

Many smartphone apps use GPS to calculate distances and speeds How can Uncertain<T> improve these apps?

slide-71
SLIDE 71

int ¡dt ¡= ¡1; ¡ ¡ Geocoordinate ¡LastLocation ¡= ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ while ¡(true) ¡{ ¡ ¡ ¡ ¡ ¡Sleep(dt); ¡// ¡wait ¡for ¡dt ¡seconds ¡ ¡ ¡ ¡ ¡ ¡Geocoordinate ¡Location ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ ¡ ¡ ¡ ¡double ¡Speed ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.Distance(Location, ¡LastLocation) ¡/ ¡dt; ¡ ¡ ¡ ¡ ¡ ¡Display(Speed); ¡ ¡ ¡ ¡ ¡if ¡(Speed ¡> ¡5) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GoodJobMessage(); ¡ ¡ ¡ ¡ ¡ ¡LastLocation ¡= ¡Location; ¡ ¡ ¡ } ¡ ¡

slide-72
SLIDE 72

int ¡dt ¡= ¡1; ¡ ¡ Geocoordinate ¡LastLocation ¡= ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ while ¡(true) ¡{ ¡ ¡ ¡ ¡ ¡Sleep(dt); ¡// ¡wait ¡for ¡dt ¡seconds ¡ ¡ ¡ ¡ ¡ ¡Geocoordinate ¡Location ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ ¡ ¡ ¡ ¡double ¡Speed ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.Distance(Location, ¡LastLocation) ¡/ ¡dt; ¡ ¡ ¡ ¡ ¡ ¡Display(Speed); ¡ ¡ ¡ ¡ ¡if ¡(Speed ¡> ¡5) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GoodJobMessage(); ¡ ¡ ¡ ¡ ¡ ¡LastLocation ¡= ¡Location; ¡ ¡ ¡ } ¡ ¡

slide-73
SLIDE 73

int ¡dt ¡= ¡1; ¡ ¡ Uncertain<Geocoordinate> ¡LastLocation ¡= ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ while ¡(true) ¡{ ¡ ¡ ¡ ¡ ¡Sleep(dt); ¡// ¡wait ¡for ¡dt ¡seconds ¡ ¡ ¡ ¡ ¡ ¡Uncertain<Geocoordinate> ¡Location ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ ¡ ¡ ¡ ¡Uncertain<double> ¡Speed ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.Distance(Location, ¡LastLocation) ¡/ ¡dt; ¡ ¡ ¡ ¡ ¡ ¡Display(Speed); ¡ ¡ ¡ ¡ ¡if ¡(Speed ¡> ¡5) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GoodJobMessage(); ¡ ¡ ¡ ¡ ¡ ¡LastLocation ¡= ¡Location; ¡ ¡ ¡ } ¡ ¡

slide-74
SLIDE 74

int ¡dt ¡= ¡1; ¡ ¡ Uncertain<Geocoordinate> ¡LastLocation ¡= ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ while ¡(true) ¡{ ¡ ¡ ¡ ¡ ¡Sleep(dt); ¡// ¡wait ¡for ¡dt ¡seconds ¡ ¡ ¡ ¡ ¡ ¡Uncertain<Geocoordinate> ¡Location ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ ¡ ¡ ¡ ¡Uncertain<double> ¡Speed ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.Distance(Location, ¡LastLocation) ¡/ ¡dt; ¡ ¡ ¡ ¡ ¡ ¡Display(Speed); ¡ ¡ ¡ ¡ ¡if ¡(Speed ¡> ¡5) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GoodJobMessage(); ¡ ¡ ¡ ¡ ¡ ¡LastLocation ¡= ¡Location; ¡ ¡ ¡ } ¡ ¡

slide-75
SLIDE 75

int ¡dt ¡= ¡1; ¡ ¡ Uncertain<Geocoordinate> ¡LastLocation ¡= ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ while ¡(true) ¡{ ¡ ¡ ¡ ¡ ¡Sleep(dt); ¡// ¡wait ¡for ¡dt ¡seconds ¡ ¡ ¡ ¡ ¡ ¡Uncertain<Geocoordinate> ¡Location ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ ¡ ¡ ¡ ¡Uncertain<double> ¡Speed ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.Distance(Location, ¡LastLocation) ¡/ ¡dt; ¡ ¡ ¡ ¡ ¡ ¡Display(Speed.E().Project()); ¡ ¡ ¡ ¡ ¡if ¡(Speed ¡> ¡5) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GoodJobMessage(); ¡ ¡ ¡ ¡ ¡ ¡LastLocation ¡= ¡Location; ¡ ¡ ¡ } ¡ ¡

slide-76
SLIDE 76

int ¡dt ¡= ¡1; ¡ ¡ Uncertain<Geocoordinate> ¡LastLocation ¡= ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ while ¡(true) ¡{ ¡ ¡ ¡ ¡ ¡Sleep(dt); ¡// ¡wait ¡for ¡dt ¡seconds ¡ ¡ ¡ ¡ ¡ ¡Uncertain<Geocoordinate> ¡Location ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ ¡ ¡ ¡ ¡Uncertain<double> ¡Speed ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.Distance(Location, ¡LastLocation) ¡/ ¡dt; ¡ ¡ ¡ ¡ ¡ ¡Display(Speed.E().Project()); ¡ ¡ ¡ ¡ ¡if ¡(Speed ¡> ¡5) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GoodJobMessage(); ¡ ¡ ¡ ¡ ¡ ¡LastLocation ¡= ¡Location; ¡ ¡ ¡ } ¡ ¡

slide-77
SLIDE 77

int ¡dt ¡= ¡1; ¡ ¡ Uncertain<Geocoordinate> ¡LastLocation ¡= ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ while ¡(true) ¡{ ¡ ¡ ¡ ¡ ¡Sleep(dt); ¡// ¡wait ¡for ¡dt ¡seconds ¡ ¡ ¡ ¡ ¡ ¡Uncertain<Geocoordinate> ¡Location ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.GetGPSLocation(); ¡ ¡ ¡ ¡ ¡Uncertain<double> ¡Speed ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPSLib.Distance(Location, ¡LastLocation) ¡/ ¡dt; ¡ ¡ ¡ ¡ ¡ ¡Display(Speed.E().Project()); ¡ ¡ ¡ ¡ ¡if ¡((Speed ¡> ¡5).E() ¡> ¡0.75) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GoodJobMessage(); ¡ ¡ ¡ ¡ ¡ ¡LastLocation ¡= ¡Location; ¡ ¡ ¡ } ¡ ¡

slide-78
SLIDE 78

walking speeds

25 50 75 100

Time Speed (km/h)

slide-79
SLIDE 79

improved walking speeds

25 50 75 100

Time Speed (km/h)

Without prior With prior

slide-80
SLIDE 80

approximate computing

Recent work uses neural networks to approximate functions, trade accuracy for performance How to reason about the error this induces? Neural networks: posterior predictive distribution

slide-81
SLIDE 81

evaluation

Approximate the Sobel operator s(p), calculating gradient of image intensity at a pixel Evaluate the conditional s(p) > 0.1, with and without Uncertain<T>

slide-82
SLIDE 82

evaluation

  • Parrot (naive approach)

20 30 40 50 60 70 80 90 100

Confidence level (%) Incorrect decisions (%)

Conditional

  • Mean

90%

slide-83
SLIDE 83

future work

Sensor applications

Less accurate sensors to save power

A programming model for uncertainty

Machine learning for non-experts

Optimisation

Lazy evaluation a promising target

slide-84
SLIDE 84

Uncertainty is a growing problem for non-expert

  • programmers. Existing abstractions are inadequate.

Other solutions are either inefficient or inaccessible. Uncertain<T> focuses on accessibility to non-experts, while still being expressive and efficient. Programmers can make principled decisions under uncertainty. With Uncertain<T>, non-expert programmers can build programs that are more concise, expressive, and correct.