Improvements in Handling of Units in Maple 2024
Maple 2024 includes several improvements to the handling of units.
Faster computation with Matrices with Units
The Statistics package
The IPS system
When working with matrices with entries with units, Maple can now perform operations much faster than before. See the Performance Improvements in Maple 2024 help page for details.
The Statistics package deals with many aspects of statistics. Its functionality is divided up into a few large parts. Nearly all commands mentioned on the Descriptive Statistics, Random Variables, and Distributions help pages will work with units.
with(Statistics):
Using a distribution will verify dimensional consistency of the units involved, and raise an error if the units are inconsistent, either because a particular parameter cannot have a (nontrivial) unit, or because multiple parameters have to agree with each other.
rv1 := RandomVariable(Normal(5*Unit(m), 2*Unit(s)));
Error, (in Statistics:-Distribution) units problem in parameters for distribution Normal; found contradictions {Distribution::(5*Units:-Unit(m)), Distribution::(2*Units:-Unit(s))}
rv1 := RandomVariable(Normal(5*Unit(m), 3*Unit(ft)));
rv1≔_R
rv2 := RandomVariable(Weibull(5*Unit(m), 2*Unit(m)));
Error, (in Statistics:-Distribution) units problem in 2nd parameter, 2*Units:-Unit(m), for distribution Weibull; found nontrivial unit, but did not expect one
rv2 := RandomVariable(Weibull(5*Unit(m), 2));
rv2≔_R0
We can compute various statistical properties of these distributions as follows.
Mean(rv1);
5⁢m
Variance(rv2);
25−25⁢π4⁢m2
Skewness(rv1 - rv2);
−61035156250⁢π⁢π−340368949−9765625⁢π32
evalf((5));
−0.5078727141
The same commands are used to compute these properties of a data sample.
sample := [.0377*Unit(ft), .578*Unit(ft), 2.05*Unit(ft), 3.60*Unit(ft), 4.92*Unit(ft), 5.45*Unit(ft), 5.75*Unit(ft), 6.21*Unit(ft), 2.77*Unit(m), 3.41*Unit(m), 4.01*Unit(m), 4.54*Unit(m), 5.41*Unit(m), 5.54*Unit(m), 5.61*Unit(m), 6.18*Unit(m), 7.21*Unit(m), 9.34*Unit(m), 13.9*Unit(m), 14.9*Unit(m)];
sample≔0.0377⁢ft,0.578⁢ft,2.05⁢ft,3.60⁢ft,4.92⁢ft,5.45⁢ft,5.75⁢ft,6.21⁢ft,2.77⁢m,3.41⁢m,4.01⁢m,4.54⁢m,5.41⁢m,5.54⁢m,5.61⁢m,6.18⁢m,7.21⁢m,9.34⁢m,13.9⁢m,14.9⁢m
Mean(sample);
15.0157430049500⁢ft
Variance(sample);
189.446615326348⁢ft2
Skewness(sample);
1.18031316013932
Cumulants of quantities with units are not well-defined. The Cumulant command checks for this and raises an error if appropriate.
Cumulant(rv1, 3);
Error, (in Statistics:-Cumulant) unexpected input: expected _R1*Units:-Unit(m) to not have units
distance := 3*Unit(m);
distance≔3⁢m
Cumulant(rv2 / distance, 3);
25⁢25⁢π36−125⁢π18+125⁢π32108
evalf((12));
0.290470418
Cumulant(sample, 3);
Error, (in Statistics:-Cumulant) unexpected input: expected Vector(20, [.1149096000e-1*Units:-Unit(m),.1761744000*Units:-Unit(m),.6248400000*Units:-Unit(m),1.097280000*Units:-Unit(m),1.499616000*Units:-Unit(m),1.661160000*Units:-Unit(m),1.752600000*Units:-Unit(m),1.892808000*Units:-Unit(m),2.77*Units:-Unit(m),3.41*Units:-Unit(m),4.01*Units:-Unit(m),4.54*Units:-Unit(m),5.41*Units:-Unit(m),5.54*Units:-Unit(m),5.61*Units:-Unit(m),6.18*Units:-Unit(m),7.21*Units:-Unit(m),9.34*Units:-Unit(m),13.9*Units:-Unit(m),14.9*Units:-Unit(m)]) to not have units
The second argument of the AbsoluteDeviation command must have the same dimension as the first argument. If it doesn't, an error is raised.
AbsoluteDeviation(sample, 5*Unit(s));
Error, (in Statistics:-AbsoluteDeviation) unable to convert `s` to `ft`
AbsoluteDeviation(sample, 2*Unit(fathom));
10.1286139500500⁢ft
AbsoluteDeviation(rv2, Mean(sample));
1.878130286⁢m
Covariance is defined for data samples with different dimensions. So is correlation. Note how the covariance has a unit, but the correlation doesn't.
Covariance(rv1 * rv2, rv1 + rv2);
125+40368949⁢π625000−5⁢25⁢π⁢5+5⁢π22⁢m3
evalf((16));
30.5302225⁢m3
Correlation(rv1 * rv2, rv1);
1143⁢25⁢π10⁢40368949−9765625⁢π
sample2 := [33.15 * Unit(N), 32.92 * Unit(N), 55.91 * Unit(N), 34.00 * Unit(N), 16.81 * Unit(N), 38.74 * Unit(N), 20.80 * Unit(N), -16.14 * Unit(N), 19.70 * Unit(N), 48.93 * Unit(N), 1.10 * Unit(N), 42.43 * Unit(N), 1.53 * Unit(N), -26.54 * Unit(N), 15.59 * Unit(N), 8.764 * Unit(N), -27.57 * Unit(N), -13.60 * Unit(N), -40.35 * Unit(N), -64.21 * Unit(N)];
sample2≔33.15⁢N,32.92⁢N,55.91⁢N,34.00⁢N,16.81⁢N,38.74⁢N,20.80⁢N,−16.14⁢N,19.70⁢N,48.93⁢N,1.10⁢N,42.43⁢N,1.53⁢N,−26.54⁢N,15.59⁢N,8.764⁢N,−27.57⁢N,−13.60⁢N,−40.35⁢N,−64.21⁢N
Covariance(sample, sample2);
−109.525825439543⁢J
Correlation(sample, sample2);
−0.813010115206344
Maple supports several so-called systems of units, which are combinations of units that are often used together. The default system is the SI system. Another system that is often used, especially in North America, is the FPS (foot-pound-second) system. For Maple 2024, we have added the IPS (inch-pound-second) system, demonstrated below.
restart;
with(Units):
Automatically loading the Units[Simple] subpackage
UseSystem(IPS);
velocity := 1*Unit(inch/second);
velocity≔ins
mass := 5*Unit(pound);
mass≔5⁢lb
velocity^2 * mass;
2540196133⁢lbf⁢in
Converting this quantity to the SI and FPS system can be done, for example, as follows.
convert((24), 'system', 'SI');
731599133573500000000000000⁢J
convert((24), 'system', 'FPS');
635588399⁢lbf⁢ft
The IPS system is also available in the Units Formatting dialog.
Maple also supports more specialized systems of units.
convert((24), 'system', 'Atomic');
3.356155884×1014⁢E0
convert((24), 'system', 'ESU');
73159913357350000000⁢erg
Download Help Document