# Wolfram Language™

## Construisez des lois dérivées en utilisant les grandeurs

Utilisez TransformedDistribution pour préciser la loi d'une fonction à valeur quantitative.

In[1]:=
```speed = \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query\$\$ = "speed of sound in air", Typeset`boxes\$\$ = TemplateBox[{ InterpretationBox[" ", 1], "\"speeds of sound in dry air at 20 \[Degree]C and 1 \ atmosphere pressure\"", "speeds of sound in dry air at 20 \[Degree]C and 1 atmosphere \ pressure", "\"SpeedOfSound\""}, "Quantity", SyntaxForm -> Mod], Typeset`allassumptions\$\$ = {{ "type" -> "MultiClash", "word" -> "", "template" -> "Assuming \${word1} is referring to \${desc1}. \ Use as \${desc2} instead. Use \"\${word3}\" as \${desc3}. Use \"\${word4}\ \" as \${desc4}.", "count" -> "4", "Values" -> {{ "name" -> "Unit", "word" -> "the input", "desc" -> "a unit", "input" -> "*MC.%7E-_*Unit-"}, { "name" -> "Formula", "word" -> "the input", "desc" -> "a formula", "input" -> "*MC.%7E-_*Formula-"}, { "name" -> "Thermodynamic", "word" -> "air", "desc" -> "a thermodynamic material", "input" -> "*MC.%7E-_*Thermodynamic-"}, { "name" -> "Chemical", "word" -> "air", "desc" -> "a chemical compound", "input" -> "*MC.%7E-_*Chemical-"}}}}, Typeset`assumptions\$\$ = {}, Typeset`open\$\$ = {1, 2}, Typeset`querystate\$\$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.8160297`7.363250959003981, "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->{398., {30., 18.}}, 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]\);```
In[2]:=
```distance\[ScriptCapitalD] = TransformedDistribution[speed*Quantity[t, "Seconds"], t \[Distributed] UniformDistribution[{2, 4}]]```
Out[2]=

Convertissez l'unité de la loi en kilomètres.

In[3]:=
`UnitConvert[distance\[ScriptCapitalD], "Kilometers"]`
Out[3]=

Utilisez TransformedDistribution pour combiner des variables aléatoires avec des grandeurs.

In[4]:=
```TransformedDistribution[ Subscript[x, 0] + v*t, {Subscript[x, 0] \[Distributed] NormalDistribution[\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query\$\$ = "2 m", Typeset`boxes\$\$ = TemplateBox[{"2", "\"m\"", "meters", "\"Meters\""}, "Quantity", SyntaxForm -> Mod], Typeset`allassumptions\$\$ = {{ "type" -> "Clash", "word" -> "m", "template" -> "Assuming \"\${word}\" is \${desc1}. Use as \ \${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "Unit", "desc" -> "a unit", "input" -> "*C.m-_*Unit-"}, { "name" -> "Variable", "desc" -> "a variable", "input" -> "*C.m-_*Variable-"}}}, { "type" -> "Unit", "word" -> "m", "template" -> "Assuming \${desc1} for \"\${word}\". Use \ \${desc2} instead", "count" -> "3", "Values" -> {{ "name" -> "Meters", "desc" -> "meters", "input" -> "UnitClash_*m.*Meters--"}, { "name" -> "MinimsUS", "desc" -> "US minims of volume", "input" -> "UnitClash_*m.*MinimsUS--"}, { "name" -> "Minutes", "desc" -> "minutes of time", "input" -> "UnitClash_*m.*Minutes--"}}}}, Typeset`assumptions\$\$ = {}, Typeset`open\$\$ = {1, 2}, Typeset`querystate\$\$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 1.4079785`7.600141016624048, "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->{86., {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\$\$ = "2 cm", Typeset`boxes\$\$ = TemplateBox[{"2", "\"cm\"", "centimeters", "\"Centimeters\""}, "Quantity", SyntaxForm -> Mod], Typeset`allassumptions\$\$ = {}, Typeset`assumptions\$\$ = {}, Typeset`open\$\$ = {1, 2}, Typeset`querystate\$\$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 3.2360033`7.961553949319721, "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->{70., {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]\)], v \[Distributed] RayleighDistribution[\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query\$\$ = "5 kmph", Typeset`boxes\$\$ = TemplateBox[{"5", RowBox[{"\"km\"", " ", "\"/\"", " ", "\"h\""}], "kilometers per hour", FractionBox["\"Kilometers\"", "\"Hours\""]}, "Quantity", SyntaxForm -> Mod], Typeset`allassumptions\$\$ = {}, Typeset`assumptions\$\$ = {}, Typeset`open\$\$ = {1, 2}, Typeset`querystate\$\$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.3549929`7.00176466057457, "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->{86., {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]\)], t \[Distributed] GammaDistribution[3, \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query\$\$ = "5 min", Typeset`boxes\$\$ = TemplateBox[{"5", "\"min\"", "minutes", "\"Minutes\""}, "Quantity", SyntaxForm -> Mod], Typeset`allassumptions\$\$ = {{ "type" -> "Clash", "word" -> "min", "template" -> "Assuming \"\${word}\" is \${desc1}. Use as \ \${desc2} instead", "count" -> "3", "Values" -> {{ "name" -> "Unit", "desc" -> "a unit", "input" -> "*C.min-_*Unit-"}, { "name" -> "OptimizationWord", "desc" -> " referring to optimization", "input" -> "*C.min-_*OptimizationWord-"}, { "name" -> "HistoricalCountry", "desc" -> "a historical country", "input" -> "*C.min-_*HistoricalCountry-"}}}, { "type" -> "Unit", "word" -> "min", "template" -> "Assuming \${desc1} for \"\${word}\". Use \ \${desc2} instead", "count" -> "3", "Values" -> {{ "name" -> "Minutes", "desc" -> "minutes of time", "input" -> "UnitClash_*min.*Minutes--"}, { "name" -> "MinimsUS", "desc" -> "US minims of volume", "input" -> "UnitClash_*min.*MinimsUS--"}, { "name" -> "ArcMinutes", "desc" -> "minutes of arc", "input" -> "UnitClash_*min.*ArcMinutes--"}}}}, Typeset`assumptions\$\$ = {}, Typeset`open\$\$ = {1, 2}, Typeset`querystate\$\$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.4070055`7.0611452715258896, "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->{101., {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[4]=

Utilisez TransformedDistribution pour combiner les magnitudes des variables aléatoires.

In[5]:=
```TransformedDistribution[QuantityMagnitude[t, "Celsius"], t \[Distributed] NormalDistribution[Quantity[293.15, "Kelvins"], Quantity[5.2, "Kelvins"]]]```
Out[5]=

Alternativement, définissez la loi de Quantity[x, unit] pour montrer que x se réfère à la magnitude de la variable aléatoire en une unité donnée.

In[6]:=
```TransformedDistribution[t, Quantity[t, "Celsius"] \[Distributed] NormalDistribution[Quantity[293.15, "Kelvins"], Quantity[5.2, "Kelvins"]]]```
Out[6]=

Par exemple, exprimez la loi de l'indice de refroidissement éolien en Amérique du Nord, en degrés Fahrenheit, en supposant certaines lois pour la température de l'air en hiver et la vitesse du vent à Chicago, IL.

In[7]:=
```wcTemp\[ScriptCapitalD] = TransformedDistribution[ 35.74 + 0.6215 QuantityMagnitude[Ta, "DegreesFahrenheit"] + (0.4275 QuantityMagnitude[Ta, "DegreesFahrenheit"] - 35.75) QuantityMagnitude[V, "Miles"/"Hours"]^+0.16, {V \[Distributed] WeibullDistribution[2.81, \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query\$\$ = "4.846 m/s", Typeset`boxes\$\$ = TemplateBox[{"4.846", RowBox[{"\"m\"", " ", "\"/\"", " ", "\"s\""}], "meters per second", FractionBox["\"Meters\"", "\"Seconds\""]}, "Quantity", SyntaxForm -> Mod], Typeset`allassumptions\$\$ = {{ "type" -> "MultiClash", "word" -> "", "template" -> "Assuming \${word1} is referring to \${desc1}. \ Use \"\${word2}\" as \${desc2}.", "count" -> "2", "Values" -> {{ "name" -> "Unit", "word" -> "m/s", "desc" -> "a unit", "input" -> "*MC.m%2Fs-_*Unit-"}, { "name" -> "Variable", "word" -> "m", "desc" -> "a variable", "input" -> "*MC.m%2Fs-_*Variable-"}}}, { "type" -> "Unit", "word" -> "m/s", "template" -> "Assuming \${desc1} for \"\${word}\". Use \ \${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "MetersPerSecond", "desc" -> "meters per second", "input" -> "UnitClash_*m%2Fs.*MetersPerSecond--"}, { "name" -> "MinutesPerSecond", "desc" -> "minutes per second", "input" -> "UnitClash_*m%2Fs.*MinutesPerSecond--"}}}}, Typeset`assumptions\$\$ = {}, Typeset`open\$\$ = {1, 2}, Typeset`querystate\$\$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.5190047`7.166716284243896, "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->{133., {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]\)], Ta \[Distributed] TriangularDistribution[{\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query\$\$ = "20 Fah", Typeset`boxes\$\$ = TemplateBox[{ "20", "\"\[Degree]F\"", "degrees Fahrenheit", "\"DegreesFahrenheit\""}, "Quantity", SyntaxForm -> Mod], Typeset`allassumptions\$\$ = {}, Typeset`assumptions\$\$ = {}, Typeset`open\$\$ = {1, 2}, Typeset`querystate\$\$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.5190113`7.166721806978768, "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->{78., {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\$\$ = "48 Fah", Typeset`boxes\$\$ = TemplateBox[{ "48", "\"\[Degree]F\"", "degrees Fahrenheit", "\"DegreesFahrenheit\""}, "Quantity", SyntaxForm -> Mod], Typeset`allassumptions\$\$ = {}, Typeset`assumptions\$\$ = {}, Typeset`open\$\$ = {1, 2}, Typeset`querystate\$\$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 1.3720224`7.588906195330978, "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->{78., {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\$\$ = "30 Fah", Typeset`boxes\$\$ = TemplateBox[{ "30", "\"\[Degree]F\"", "degrees Fahrenheit", "\"DegreesFahrenheit\""}, "Quantity", SyntaxForm -> Mod], Typeset`allassumptions\$\$ = {}, Typeset`assumptions\$\$ = {}, Typeset`open\$\$ = {1, 2}, Typeset`querystate\$\$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.2719958`6.8861071914606615, "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->{78., {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[7]=

Tracez l'estimation de la densité de noyau lisse de l'indice de refroidissement éolien à partir de l'échantillon de population.

Afficher l'entrée complète de Wolfram Language
In[8]:=
```SmoothHistogram[RandomVariate[wcTemp\[ScriptCapitalD], 10^5], Filling -> Axis, AxesLabel -> {"\[Degree]F"}, Epilog -> {Directive[Dashed, Red], InfiniteLine[{{32, 0}, {32, 1}}]}]```
Out[8]=