Solutions to Assignments¶
1) World Oil Reserves vs. Consumption¶
Which share of countries consume 75% of
oil_consumption()
?>>> Effects(oil_consumption()).attain_effects(3/4) 0.167How much of
co2()
emissions account the biggest five emitting countries for?>>> Effects(co2()).attain_causes(5/len(co2())) 0.606Which number of countries is required to attain 75% of
oil_reserves()
?>>> Effects(oil_reserves()).attain_effects(0.75)*len(oil_reserves()) 7.992How many years do 10% of the
oil_reserves()
last for 10% ofoil_consumption()
(note: reserves are in million barrels per year, consumption in thousand barrels per day)?>>> (Effects(oil_reserves()).attain_causes(0.1)*sum(oil_reserves()))/((Effects(oil_consumption()).attain_causes(0.1)*sum(oil_consumption()))/1000/365) 3295.5143003164517
2) Euro Coins & Bank Notes¶
Is a pareto distribution present for
euro_banknotes()
?>>> Effects(euro_banknotes()).pareto TrueIf, which distribution is stronger, that for the
euro_coins()
or for theeuro_banknotes()
?>>> coins = Effects(euro_coins()) >>> notes = Effects(euro_banknotes()) >>> if notes.pareto: ... print(notes.ratio < coins.ratio) FalseAs the ratio of
euro_banknotes()
is less than of theeuro_coins()
, the coins have the stronger pareto distribution. Remember: As the ratio depends on the entropy, a smaller ratio means less entropy, less entropy means stronger pareto distribution.
How much Euros do the largest 10% of
euro_banknotes()
represent?>>> notes.attain_causes(0.1)*sum(euro_banknotes())/1000 461.80144999999993462 billion Euros.
How much Euros do the largest 50% of
euro_coins()
represent?>>> coins.attain_causes(0.5)*sum(euro_coins())/1000 23.70101360000000324 billion Euros.
3) Swiss Railway Passenger Frequency¶
Suppose Swiss railways classifies railway stations into A (60% of passenger volume), B (60 to 80%) and C (80 to 100% of volume). Which share of causes would each class represent?
>>> class_a = passengers.attain_effects(0.6) # 0 to 60% >>> class_b = passengers.attain_effects(0.8)-class_a # 60 to 80% >>> class_c = passengers.attain_effects(1.0)-class_a-class_b # 80 to 100% >>> print('A: {}, B: {}, C: {}'.format(class_a, class_b, class_c)) A: 0.051, B: 0.093, C: 0.81199999999999990 to 5% of stations make up 60% of passengers, the next 9.3% (5.1 to 14.4%) another 20% and the final 81% make up for only 20% of passengers.
Following your results from 1., how many stations fall into the categories A, B and C?
>>> [cls*len(swiss_rail_passengers()) for cls in [class_a, class_b, class_c]] [37.647999999999996, 66.608, 619.744]A holds 37 stations, B 67 and C 588.
Determine the corresponding threshold values of passenger frequency enabling you to allocate each single station to class A, B or C.
>>> [passengers.separate_effects(threshold) for threshold in [0.6, 0.8]] [(19200.0, 1, 1), (6000.0, 5, 5)]A station belongs to class A if it has 19200 or more passengers per work day. It falls into class B if it is the fifth of the five stations with 6000 passengers per day. Otherwise it belongs to class C.
4) Exoplanets¶
How many exoplanets fall into the interval of 30 to 60% of total mass?
>>> masses.interval_effects(0.3, 0.6)*len(exoplanets()) 33.3933 exoplanets fall into the interval of 30 to 60% of total mass.
- Which exoplanets are this namely?
>>> list(keys_in_effects_interval(eplanets, 'mass', 0.3, 0.6)) ['2M 0122-24 b', '2M 2140+16 b', 'Kepler-57 b', 'Kepler-53 b', 'HD 41004 B b', 'Kepler-39 b', 'CT Cha b', 'HN Peg b', 'Kepler-53 c', '1RXS 1609 b', 'kappa And b', '2M 0219-39 b', 'Kepler-27 c', 'WISE 0458+6434 b', 'XO-3 b', 'Ross 458 (AB) c', 'GU Psc b', 'WASP-18 b', 'Kepler-52 c', 'CoRoT-27 b', 'HR 8799 c', 'HR 8799 d', 'Kepler-448 b', 'Kepler-75 b', 'SWEEPS-11 ', 'Kepler-27 b', 'ROXs 42B b', 'HAT-P-2 b', 'Kepler-52 b', 'Kepler-14 b', 'CoRoT-14 b', 'WASP-14 b']
- Find out the exoplanets that fall into the interval of 70 to 80% of total mass but not into the interval of 10 to 90% of volume.
>>> set(keys_in_effects_interval(eplanets, 'mass', 0.7, 0.8)).difference(set(keys_in_effects_interval(eplanets, 'volume', 0.1, 0.9))) {'CoRoT-10 b', 'CoRoT-17 b', 'HATS-22 b', 'HD 118203 b', 'K2-33 b', 'Kepler-419 b', 'Kepler-58 c', 'Kepler-59 b', 'POTS-1 b', 'WASP-43 b', 'WASP-8 b'}
5) Fibonacci Sequences¶
Check whether a pareto distribution can be observed for fibonacci series. If, all or just from/to a specific fibonacci series?
>>> [Effects(fib_list(n)) for n in range(5, 20)] [<pareto not present [1.04]: 1/1 causes => 1/1 effects [total ∆: 0.0 % points]>, <pareto not present [1.01]: 1/3 causes => 2/3 effects [total ∆: 0.0 % points]>, <pareto present [0.977]: 3/10 causes => 2/3 effects [total ∆: 3.1 % points]>, <pareto present [0.94]: 1/4 causes => 2/3 effects [total ∆: 3.0 % points]>, <pareto present [0.905]: 1/3 causes => 4/5 effects [total ∆: 2.2 % points]>, <pareto present [0.872]: 1/5 causes => 3/5 effects [total ∆: 2.5 % points]>, <pareto present [0.842]: 1/1 causes => 1/1 effects [total ∆: 0.0 % points]>, <pareto present [0.814]: 1/4 causes => 4/5 effects [total ∆: 3.3 % points]>, <pareto present [0.789]: 3/10 causes => 9/10 effects [total ∆: 5.1 % points]>, <pareto present [0.766]: 3/10 causes => 9/10 effects [total ∆: 5.9 % points]>, <pareto present [0.745]: 1/5 causes => 4/5 effects [total ∆: 3.5 % points]>, <pareto present [0.726]: 3/10 causes => 9/10 effects [total ∆: 2.3 % points]>, <pareto present [0.709]: 3/10 causes => 9/10 effects [total ∆: 1.6 % points]>, <pareto present [0.693]: 1/3 causes => 9/10 effects [total ∆: 4.4 % points]>, <pareto present [0.679]: 1/1 causes => 1/1 effects [total ∆: 0.0 % points]>]A pareto distribution is present from the seventh fibonacci sequence on, that is [0, 1, 1, 2, 3, 5, 8].