Travel Planning
The average speed of cars traveling from Indianapolis, Indiana, to Chicago, Illinois, is described by a TriangularDistribution.
In[1]:=
![Click for copyable input](assets.en/travel-planning/In_26.png)
speed\[ScriptCapitalD] = TriangularDistribution[{\!\(\*
NamespaceBox["LinguisticAssistant",
DynamicModuleBox[{Typeset`query$$ = "55 mi/h", Typeset`boxes$$ =
TemplateBox[{"55",
RowBox[{"\"mi\"", " ", "\"/\"", " ", "\"h\""}], "miles per hour",
FractionBox["\"Miles\"", "\"Hours\""]}, "Quantity",
SyntaxForm -> Mod], Typeset`allassumptions$$ = {},
Typeset`assumptions$$ = {}, Typeset`open$$ = {1, 2},
Typeset`querystate$$ = {
"Online" -> True, "Allowed" -> True,
"mparse.jsp" -> 3.9373779`8.046752092819743,
"Messages" -> {}}},
DynamicBox[ToBoxes[
AlphaIntegration`LinguisticAssistantBoxes["45", 4, Automatic,
Dynamic[Typeset`query$$],
Dynamic[Typeset`boxes$$],
Dynamic[Typeset`allassumptions$$],
Dynamic[Typeset`assumptions$$],
Dynamic[Typeset`open$$],
Dynamic[Typeset`querystate$$]], StandardForm],
ImageSizeCache->{94., {8., 16.}},
TrackedSymbols:>{
Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$,
Typeset`assumptions$$, Typeset`open$$,
Typeset`querystate$$}],
DynamicModuleValues:>{},
UndoTrackedVariables:>{Typeset`open$$}],
BaseStyle->{"Deploy"},
DeleteWithContents->True,
Editable->False,
SelectWithContents->True]\), \!\(\*
NamespaceBox["LinguisticAssistant",
DynamicModuleBox[{Typeset`query$$ = "82 mph", Typeset`boxes$$ =
TemplateBox[{"82",
RowBox[{"\"mi\"", " ", "\"/\"", " ", "\"h\""}], "miles per hour",
FractionBox["\"Miles\"", "\"Hours\""]}, "Quantity",
SyntaxForm -> Mod], Typeset`allassumptions$$ = {},
Typeset`assumptions$$ = {}, Typeset`open$$ = {1, 2},
Typeset`querystate$$ = {
"Online" -> True, "Allowed" -> True,
"mparse.jsp" -> 0.2656176`6.875801841788495,
"Messages" -> {}}},
DynamicBox[ToBoxes[
AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic,
Dynamic[Typeset`query$$],
Dynamic[Typeset`boxes$$],
Dynamic[Typeset`allassumptions$$],
Dynamic[Typeset`assumptions$$],
Dynamic[Typeset`open$$],
Dynamic[Typeset`querystate$$]], StandardForm],
ImageSizeCache->{94., {8., 16.}},
TrackedSymbols:>{
Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$,
Typeset`assumptions$$, Typeset`open$$,
Typeset`querystate$$}],
DynamicModuleValues:>{},
UndoTrackedVariables:>{Typeset`open$$}],
BaseStyle->{"Deploy"},
DeleteWithContents->True,
Editable->False,
SelectWithContents->True]\)}, \!\(\*
NamespaceBox["LinguisticAssistant",
DynamicModuleBox[{Typeset`query$$ = "72 mph", Typeset`boxes$$ =
TemplateBox[{"72",
RowBox[{"\"mi\"", " ", "\"/\"", " ", "\"h\""}], "miles per hour",
FractionBox["\"Miles\"", "\"Hours\""]}, "Quantity",
SyntaxForm -> Mod], Typeset`allassumptions$$ = {},
Typeset`assumptions$$ = {}, Typeset`open$$ = {1, 2},
Typeset`querystate$$ = {
"Online" -> True, "Allowed" -> True,
"mparse.jsp" -> 0.250013`6.8495075848939235,
"Messages" -> {}}},
DynamicBox[ToBoxes[
AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic,
Dynamic[Typeset`query$$],
Dynamic[Typeset`boxes$$],
Dynamic[Typeset`allassumptions$$],
Dynamic[Typeset`assumptions$$],
Dynamic[Typeset`open$$],
Dynamic[Typeset`querystate$$]], StandardForm],
ImageSizeCache->{94., {8., 16.}},
TrackedSymbols:>{
Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$,
Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}],
DynamicModuleValues:>{},
UndoTrackedVariables:>{Typeset`open$$}],
BaseStyle->{"Deploy"},
DeleteWithContents->True,
Editable->False,
SelectWithContents->True]\)]
Out[1]=
![](assets.en/travel-planning/O_24.png)
The probability density function for the speed distribution.
In[2]:=
![Click for copyable input](assets.en/travel-planning/In_27.png)
Plot[PDF[speed\[ScriptCapitalD], Quantity[x, "mph"]], {x, 50, 85}]
Out[2]=
![](assets.en/travel-planning/O_25.png)
Calculate the distance between the cities, assuming driving.
show complete Wolfram Language input
Out[3]=
![](assets.en/travel-planning/O_26.png)
In[4]:=
![Click for copyable input](assets.en/travel-planning/In_29.png)
distance =
TravelDistance[{Entity[
"City", {"Indianapolis", "Indiana", "UnitedStates"}],
Entity["City", {"Chicago", "Illinois", "UnitedStates"}]},
TravelMethod -> "Driving"]
Out[4]=
![](assets.en/travel-planning/O_27.png)
Find the expected time of travel.
In[5]:=
![Click for copyable input](assets.en/travel-planning/In_30.png)
Expectation[distance/v, v \[Distributed] speed\[ScriptCapitalD]]
Out[5]=
![](assets.en/travel-planning/O_28.png)
Convert to hours and minutes.
In[6]:=
![Click for copyable input](assets.en/travel-planning/In_31.png)
Expectation[distance/v, v \[Distributed] speed\[ScriptCapitalD]];
UnitConvert[%, MixedUnit[{"Hours", "Minutes"}]]
Out[6]=
![](assets.en/travel-planning/O_29.png)
Assuming gas mileage as a function of car speed is given by the following interpolating function, the expected amount of gas needed for the trip can be calculated using NExpectation.
In[7]:=
![Click for copyable input](assets.en/travel-planning/In_32.png)
mpg = Interpolation[{Quantity[{40, 50, 60, 70, 80}, "miles per hour"],
Quantity[{33, 32, 28, 25, 20}, "miles per gallon"]} //
Transpose, InterpolationOrder -> 1];
In[8]:=
![Click for copyable input](assets.en/travel-planning/In_33.png)
NExpectation[distance/mpg[v], v \[Distributed] speed\[ScriptCapitalD]]
Out[8]=
![](assets.en/travel-planning/O_30.png)