Wolfram言語

確率と統計における数量

旅行の計画

インディアナ州インディアナポリスからイリノイ州シカゴまで車で移動する場合の平均速度はTriangularDistributionで表すことができる.

In[1]:=
Click for copyable input
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]=

速度分布の確率密度関数.

In[2]:=
Click for copyable input
Plot[PDF[speed\[ScriptCapitalD], Quantity[x, "mph"]], {x, 50, 85}]
Out[2]=

運転するものと仮定して,都市間の距離を計算する.

完全なWolfram言語入力を表示する
In[3]:=
Click for copyable input
GeoGraphics[ Style[Line[ TravelDirections[{Entity[ "City", {"Indianapolis", "Indiana", "UnitedStates"}], Entity["City", {"Chicago", "Illinois", "UnitedStates"}]}]], Thick, Red], GeoBackground -> GeoStyling["StreetMap"], GeoRange -> Quantity[100, "Miles"]]
Out[3]=
In[4]:=
Click for copyable input
distance = TravelDistance[{Entity[ "City", {"Indianapolis", "Indiana", "UnitedStates"}], Entity["City", {"Chicago", "Illinois", "UnitedStates"}]}, TravelMethod -> "Driving"]
Out[4]=

期待される移動時間を求める.

In[5]:=
Click for copyable input
Expectation[distance/v, v \[Distributed] speed\[ScriptCapitalD]]
Out[5]=

時間と分に変換する.

In[6]:=
Click for copyable input
Expectation[distance/v, v \[Distributed] speed\[ScriptCapitalD]]; UnitConvert[%, MixedUnit[{"Hours", "Minutes"}]]
Out[6]=

車の速度の関数としての燃費効率が以下の補間関数で与えられると仮定すると,移動に必要なガソリンの期待量はNExpectationを使って計算することができる.

In[7]:=
Click for copyable input
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
NExpectation[distance/mpg[v], v \[Distributed] speed\[ScriptCapitalD]]
Out[8]=

関連する例

de en es fr ko pt-br ru zh