-
-
Save dfrib/58cf872ded63a5985924 to your computer and use it in GitHub Desktop.
Matlab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Data from @chux answer: http://stackoverflow.com/a/35326915/4573247 | |
data = [ | |
1073741824 23567395117; | |
536870912 11411566988; | |
268435456 5519718329; | |
134217728 2666826555; | |
67108864 1286897093; | |
33554432 620190504; | |
16777216 298466265; | |
8388608 143418602; | |
4194304 68802063; | |
2097152 32947406; | |
1048576 15746897; | |
524288 7510048; | |
262144 3573331; | |
131072 1695816; | |
65536 802493; | |
32768 378537; | |
16384 177921; | |
8192 83286; | |
4096 38803; | |
2048 17973; | |
1024 8275; | |
512 3782; | |
256 1713; | |
128 765; | |
64 337; | |
32 145; | |
16 61; | |
8 24; | |
4 9; | |
2 3; | |
1 1]; | |
n=flipud(data(:,1)); | |
exact = flipud(data(:,2)); | |
calculated = n.*log(n) + n - log(n); | |
[exact round(calculated) abs(exact-calculated)./exact] | |
% exact calculated relative difference | |
% (rounded to integer) | |
ans = | |
1 1 0 | |
3 3 0.102284273146685 | |
9 8 0.0934574351822586 | |
24 23 0.0601628836767145 | |
61 58 0.0559208060066112 | |
145 139 0.0383599104359205 | |
337 326 0.0326123612710407 | |
765 744 0.0271792895192269 | |
1713 1670 0.025090339554998 | |
3782 3700 0.0217387933910132 | |
8275 8115 0.0193479568425087 | |
17973 17656 0.0176600976649259 | |
38803 38157 0.0166416912940827 | |
83286 82000 0.0154360729586646 | |
177921 175366 0.0143624213690899 | |
378537 373453 0.0134298497079125 | |
802493 792342 0.0126488235437116 | |
1695816 1675547 0.0119521223092989 | |
3573331 3532810 0.0113397655119373 | |
7510048 7429041 0.0107864741702837 | |
15746897 15584912 0.0102867823982787 | |
32947406 32623472 0.00983184047849265 | |
68802063 68154229 0.00941591569702434 | |
143418602 142123012 0.00903362807751623 | |
298466265 295875119 0.00868153860687559 | |
620190504 615008413 0.00835564377880152 | |
1286897093 1276533163 0.00805342587336599 | |
2666826555 2646098982 0.007772373714499 | |
5519718329 5478263262 0.00751035908953358 | |
11411566988 11328657102 0.00726542514647679 | |
23567395117 23401575342 0.00703598231049359 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment