# Wolfram 语言™

## 隧道

TunnelData 提供关于隧道的信息，比如它们的长度和位置.

In[1]:=
`tunnels = TunnelData[];`
In[2]:=
`Length[tunnels]`
Out[2]=

In[3]:=
`rawData = TunnelData[tunnels, {"Countries", "Length"}];`

In[4]:=
`data = DeleteMissing[rawData, 1, 2];`

In[5]:=
`data[[All, 2]] = UnitConvert[N[data[[All, 2]]], "Miles"];`
In[6]:=
`lengths = data[[All, 2]];`
In[7]:=
`MinMax[lengths]`
Out[7]=
In[8]:=
```h = Histogram[lengths, {1, 12, .5}, PDF, FrameLabel -> Automatic, PlotTheme -> "Detailed"]```
Out[8]=

In[9]:=
```dist = MixtureDistribution[{w1, w2}, {ParetoDistribution[a1, a2, a3, a4], WeibullDistribution[b1, b2]}];```
In[10]:=
`edist = EstimatedDistribution[lengths, dist]`
Out[10]=

In[11]:=
`DistributionFitTest[lengths, dist, "TestDataTable"]`
Out[11]=

In[12]:=
```Show[h, Plot[PDF[edist, Quantity[x, "Miles"]], {x, 1, 12}, PlotRange -> All] // Quiet]```
Out[12]=

In[13]:=
`res = GroupBy[data, First, Flatten[Take[#, All, -1]] &];`

In[14]:=
`shared = Select[Keys[res], Length[#] > 1 &]`
Out[14]=

In[15]:=
```split = GroupBy[ Flatten[Map[{{{#[[1]]}, res[#]}, {{#[[2]]}, res[#]}} &, shared], 1], First, Flatten[#[[All, 2]]] &];```
In[16]:=
`together = Join[KeyDrop[res, shared], split, 2];`
In[17]:=
```tc = SortBy[Select[Normal[together], Length[#[[2]]] >= 10 &], Length@*Last];```
In[18]:=
```DistributionChart[tc[[All, 2]], ChartLabels -> tc[[All, 1, 1]], BarOrigin -> Left, BarSpacing -> .3, FrameLabel -> {"Miles"}, LabelingFunction -> (Placed[Length[#1], After] &), ChartStyle -> "SandyTerrain", ImageSize -> Large]```
Out[18]=

In[19]:=
```vals = KeyMap[First, Map[Total, together]]; title = Style["tunnel mileage", 24, Bold, GrayLevel[.2], FontFamily -> "Osaka"]; GeoRegionValuePlot[vals, GeoProjection -> "Mercator", GeoRange -> {{-65, 80}, {-170, 190}}, PlotLegends -> Automatic, ColorFunction -> (ColorData["StarryNightColors", 2 #] &), Epilog -> Inset[title, {30, -65}], ImageSize -> 500]```
Out[19]=