Tunnels
TunnelData provides information about tunnels, such as their length and the location.
![Click for copyable input](assets.en/tunnels/In_55.png)
tunnels = TunnelData[];
![Click for copyable input](assets.en/tunnels/In_56.png)
Length[tunnels]
![](assets.en/tunnels/O_47.png)
For each tunnel, find its length and location given by country or countries.
![Click for copyable input](assets.en/tunnels/In_57.png)
rawData = TunnelData[tunnels, {"Countries", "Length"}];
Clean the data to remove missing values.
![Click for copyable input](assets.en/tunnels/In_58.png)
data = DeleteMissing[rawData, 1, 2];
Convert the length data to miles.
![Click for copyable input](assets.en/tunnels/In_59.png)
data[[All, 2]] = UnitConvert[N[data[[All, 2]]], "Miles"];
![Click for copyable input](assets.en/tunnels/In_60.png)
lengths = data[[All, 2]];
![Click for copyable input](assets.en/tunnels/In_61.png)
MinMax[lengths]
![](assets.en/tunnels/O_48.png)
![Click for copyable input](assets.en/tunnels/In_62.png)
h = Histogram[lengths, {1, 12, .5}, PDF, FrameLabel -> Automatic,
PlotTheme -> "Detailed"]
![](assets.en/tunnels/O_49.png)
The data might be described by a mixture of long-tailed distributions.
![Click for copyable input](assets.en/tunnels/In_63.png)
dist = MixtureDistribution[{w1,
w2}, {ParetoDistribution[a1, a2, a3, a4],
WeibullDistribution[b1, b2]}];
![Click for copyable input](assets.en/tunnels/In_64.png)
edist = EstimatedDistribution[lengths, dist]
![](assets.en/tunnels/O_50.png)
Test goodness of fit against the parametric family mixture distributions.
![Click for copyable input](assets.en/tunnels/In_65.png)
DistributionFitTest[lengths, dist, "TestDataTable"]
![](assets.en/tunnels/O_51.png)
Plot the PDF of the fitted distribution against the histogram.
![Click for copyable input](assets.en/tunnels/In_66.png)
Show[h, Plot[PDF[edist, Quantity[x, "Miles"]], {x, 1, 12},
PlotRange -> All] // Quiet]
![](assets.en/tunnels/O_52.png)
Visualize the locations of the tunnels.
Group by country.
![Click for copyable input](assets.en/tunnels/In_67.png)
res = GroupBy[data, First, Flatten[Take[#, All, -1]] &];
Some tunnels are located in more than one country.
![Click for copyable input](assets.en/tunnels/In_68.png)
shared = Select[Keys[res], Length[#] > 1 &]
![](assets.en/tunnels/O_53.png)
Distribute the shared tunnels and select countries that have at least 10 tunnels. Plot the length distribution chart.
![](assets.en/tunnels/O_54.png)
The total tunnel mileage per country with shared tunnels included in full length for each country.
![](assets.en/tunnels/O_55.png)