jsxgraph 1.14.0 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -3
- package/distrib/docs/3d_linspace3d.js.html +16 -10
- package/distrib/docs/3d_point3d.js.html +0 -5
- package/distrib/docs/3d_sphere3d.js.html +92 -69
- package/distrib/docs/3d_view3d.js.html +24 -16
- package/distrib/docs/Angle.html +7 -7
- package/distrib/docs/CircumcircleSector.html +2 -2
- package/distrib/docs/Conic.html +1 -1
- package/distrib/docs/Ellipse.html +23 -1
- package/distrib/docs/Hyperbola.html +24 -1
- package/distrib/docs/JXG.Board.infobox.html +1 -1
- package/distrib/docs/JXG.Board_.html +130 -130
- package/distrib/docs/JXG.CanvasRenderer.html +10 -10
- package/distrib/docs/JXG.Composition.html +3 -3
- package/distrib/docs/JXG.GeometryElement.html +26 -26
- package/distrib/docs/JXG.Math.Numerics.html +45 -47
- package/distrib/docs/JXG.Math.Statistics.html +14 -15
- package/distrib/docs/JXG.Math.Tiling.html +3 -7
- package/distrib/docs/JXG.Math.html +101 -83
- package/distrib/docs/JXG.Point3D.html +2 -2
- package/distrib/docs/JXG.SVGRenderer.html +12 -12
- package/distrib/docs/JXG.Sphere3D.html +1255 -2
- package/distrib/docs/JXG.View3D.html +29 -29
- package/distrib/docs/JXG.html +20 -20
- package/distrib/docs/MajorSector.html +1 -1
- package/distrib/docs/MinorSector.html +1 -1
- package/distrib/docs/NonReflexAngle.html +1 -1
- package/distrib/docs/Parabola.html +1 -1
- package/distrib/docs/Point3D.html +1 -1
- package/distrib/docs/ReflexAngle.html +1 -1
- package/distrib/docs/Sector.html +12 -12
- package/distrib/docs/Sphere3D.html +17 -1
- package/distrib/docs/View3D.html +1 -1
- package/distrib/docs/base_board.js.html +63 -13
- package/distrib/docs/base_composition.js.html +3 -3
- package/distrib/docs/base_constants.js.html +1 -1
- package/distrib/docs/base_element.js.html +2 -1
- package/distrib/docs/base_text.js.html +2 -2
- package/distrib/docs/element_conic.js.html +35 -1
- package/distrib/docs/element_sector.js.html +6 -3
- package/distrib/docs/index.html +1 -1
- package/distrib/docs/math_math.js.html +64 -35
- package/distrib/docs/math_numerics.js.html +13 -12
- package/distrib/docs/math_statistics.js.html +19 -19
- package/distrib/docs/math_tiling.js.html +6 -288
- package/distrib/docs/parser_jessiecode.js.html +1 -1
- package/distrib/docs/renderer_canvas.js.html +7 -6
- package/distrib/docs/renderer_svg.js.html +15 -7
- package/distrib/docs/scripts/jsxgraphcore.js +2 -2
- package/distrib/docs/styles/jsxgraph.css +1 -1
- package/distrib/docs/utils_type.js.html +11 -4
- package/distrib/geogebra.min.js +1 -1
- package/distrib/geonext.min.js +1 -1
- package/distrib/index.d.ts +11 -0
- package/distrib/intergeo.min.js +1 -1
- package/distrib/jsxgraph.css +1 -1
- package/distrib/jsxgraphcore.js +2 -2
- package/distrib/jsxgraphcore.mjs +2 -2
- package/distrib/jsxgraphcore.mjs.map +1 -1
- package/distrib/jsxgraphsrc.js +380 -496
- package/distrib/jsxgraphsrc.mjs +380 -496
- package/distrib/jsxgraphsrc.mjs.map +1 -1
- package/package.json +10 -12
- package/src/3d/linspace3d.js +16 -10
- package/src/3d/point3d.js +0 -5
- package/src/3d/sphere3d.js +92 -69
- package/src/3d/view3d.js +24 -16
- package/src/base/board.js +63 -13
- package/src/base/composition.js +3 -3
- package/src/base/constants.js +1 -1
- package/src/base/element.js +2 -1
- package/src/base/text.js +2 -2
- package/src/element/conic.js +35 -1
- package/src/element/sector.js +6 -3
- package/src/index.d.ts +11 -0
- package/src/math/math.js +64 -35
- package/src/math/numerics.js +13 -12
- package/src/math/statistics.js +19 -19
- package/src/math/tiling.js +6 -288
- package/src/parser/jessiecode.js +1 -1
- package/src/renderer/canvas.js +7 -6
- package/src/renderer/svg.js +15 -7
- package/src/utils/type.js +11 -4
- package/src/unused/bst.js +0 -475
- package/src/unused/heap.js +0 -135
- package/src/unused/locus.js +0 -162
- package/src/unused/server/JXG.py +0 -74
- package/src/unused/server/JXGServer.py +0 -94
- package/src/unused/server/JXGServerModule.py +0 -9
- package/src/unused/server/README.md +0 -63
- package/src/unused/server/RStats.py +0 -45
- package/src/unused/server/YahooFinance.py +0 -81
- package/src/unused/server/fft.py +0 -136
- package/src/unused/server/geoloci.py +0 -210
- package/src/unused/server/jxggroebner.py +0 -219
- package/src/unused/server/jxgtestplugin.py +0 -19
- package/src/unused/server/server.js +0 -280
- package/src/unused/sketch.js +0 -2895
- package/src/unused/symbolic.js +0 -416
package/src/element/sector.js
CHANGED
|
@@ -298,11 +298,11 @@ JXG.createSector = function (board, parents, attributes) {
|
|
|
298
298
|
s = el.line1.point1.coords;
|
|
299
299
|
} else if (
|
|
300
300
|
el.line1.point2.Dist(el.line2.point1) < eps ||
|
|
301
|
-
el.line1.point2.Dist(el.line2.
|
|
301
|
+
el.line1.point2.Dist(el.line2.point2) < eps
|
|
302
302
|
) {
|
|
303
303
|
s = el.line1.point2.coords;
|
|
304
304
|
} else {
|
|
305
|
-
|
|
305
|
+
JXG.warn(
|
|
306
306
|
"JSXGraph warning: Can't create Sector from parallel lines with no common defining point."
|
|
307
307
|
);
|
|
308
308
|
}
|
|
@@ -383,10 +383,13 @@ JXG.createSector = function (board, parents, attributes) {
|
|
|
383
383
|
B = l1.point1.coords.usrCoords;
|
|
384
384
|
} else if (
|
|
385
385
|
l1.point2.Dist(l2.point1) < eps ||
|
|
386
|
-
l1.point2.Dist(l2.
|
|
386
|
+
l1.point2.Dist(l2.point2) < eps
|
|
387
387
|
) {
|
|
388
388
|
B = l1.point2.coords.usrCoords;
|
|
389
389
|
} else {
|
|
390
|
+
JXG.warn(
|
|
391
|
+
"JSXGraph warning: sector from parallel lines with no common defining point."
|
|
392
|
+
);
|
|
390
393
|
}
|
|
391
394
|
}
|
|
392
395
|
|
package/src/index.d.ts
CHANGED
|
@@ -5078,6 +5078,17 @@ declare namespace JXG {
|
|
|
5078
5078
|
id: string | unknown | Function,
|
|
5079
5079
|
onlyByIdOrName: boolean
|
|
5080
5080
|
): GeometryElement | Composition;
|
|
5081
|
+
/**
|
|
5082
|
+
* Sets an arbitrary number of attributes. Accepts an object (`{key1: value1, key2: value2, ...}`),
|
|
5083
|
+
* a string (`'key:value'`), or an array (`['key', value]`). Some board attributes are immutable,
|
|
5084
|
+
* like e.g. the renderer type.
|
|
5085
|
+
* @param attr An object with attributes.
|
|
5086
|
+
* @param force If true the attributes are set regardless of the previous setting was identical.
|
|
5087
|
+
*/
|
|
5088
|
+
setAttribute(
|
|
5089
|
+
attr: Partial<BoardAttributes> | string | [string, unknown],
|
|
5090
|
+
force?: boolean
|
|
5091
|
+
): Board;
|
|
5081
5092
|
/**
|
|
5082
5093
|
*
|
|
5083
5094
|
*/
|
package/src/math/math.js
CHANGED
|
@@ -682,10 +682,10 @@ JXG.Math = {
|
|
|
682
682
|
}),
|
|
683
683
|
|
|
684
684
|
/**
|
|
685
|
-
* Calculates the cosine
|
|
685
|
+
* Calculates the hyperbolic cosine of \\(x\\).
|
|
686
686
|
* @function
|
|
687
687
|
* @param {Number} x The number the cosine hyperbolicus will be calculated of.
|
|
688
|
-
* @returns {Number}
|
|
688
|
+
* @returns {Number} Hyperbolic cosine of the given value.
|
|
689
689
|
*/
|
|
690
690
|
cosh:
|
|
691
691
|
Math.cosh ||
|
|
@@ -694,10 +694,10 @@ JXG.Math = {
|
|
|
694
694
|
},
|
|
695
695
|
|
|
696
696
|
/**
|
|
697
|
-
*
|
|
697
|
+
* Hyperbolic sine of \\(x\\).
|
|
698
698
|
* @function
|
|
699
|
-
* @param {Number} x The number the sine
|
|
700
|
-
* @returns {Number}
|
|
699
|
+
* @param {Number} x The number the hyperbolic sine will be calculated of.
|
|
700
|
+
* @returns {Number} Hyperbolic sine of the given value.
|
|
701
701
|
*/
|
|
702
702
|
sinh:
|
|
703
703
|
Math.sinh ||
|
|
@@ -706,7 +706,7 @@ JXG.Math = {
|
|
|
706
706
|
},
|
|
707
707
|
|
|
708
708
|
/**
|
|
709
|
-
*
|
|
709
|
+
* Inverse hyperbolic cosine of a number.
|
|
710
710
|
* @function
|
|
711
711
|
* @param {Number} x
|
|
712
712
|
* @returns {Number}
|
|
@@ -718,7 +718,7 @@ JXG.Math = {
|
|
|
718
718
|
},
|
|
719
719
|
|
|
720
720
|
/**
|
|
721
|
-
*
|
|
721
|
+
* Inverse hyperbolic sine of a number
|
|
722
722
|
* @function
|
|
723
723
|
* @param {Number} x
|
|
724
724
|
* @returns {Number}
|
|
@@ -795,7 +795,7 @@ JXG.Math = {
|
|
|
795
795
|
},
|
|
796
796
|
|
|
797
797
|
/**
|
|
798
|
-
* Computes cube root of real number
|
|
798
|
+
* Computes cube root of real number.
|
|
799
799
|
* Polyfill for Math.cbrt().
|
|
800
800
|
*
|
|
801
801
|
* @function
|
|
@@ -915,7 +915,11 @@ JXG.Math = {
|
|
|
915
915
|
},
|
|
916
916
|
|
|
917
917
|
/**
|
|
918
|
-
* A square & multiply algorithm to compute base to the power of exponent
|
|
918
|
+
* A square & multiply algorithm to compute `base` to the power of `exponent`.
|
|
919
|
+
* That is, for base \\(b\\) and integer exponent \\(e\\) it is a fast method to compute
|
|
920
|
+
* \\[ b^e .\\]
|
|
921
|
+
* For non-integer values of `exponent`, JavaScript's `Math.pow` is used.
|
|
922
|
+
*
|
|
919
923
|
* Implementated by Wolfgang Riedl.
|
|
920
924
|
*
|
|
921
925
|
* @param {Number} base
|
|
@@ -950,16 +954,17 @@ JXG.Math = {
|
|
|
950
954
|
},
|
|
951
955
|
|
|
952
956
|
/**
|
|
953
|
-
* Greatest common divisor (gcd) of two numbers.
|
|
954
|
-
* See {@link
|
|
957
|
+
* Greatest common divisor (gcd) of two finite, non-zero integer numbers.
|
|
958
|
+
* See {@link https://rosettacode.org/wiki/Greatest_common_divisor#JavaScript rosettacode.org}.
|
|
955
959
|
*
|
|
956
|
-
* @param {Number} a First number
|
|
957
|
-
* @param {Number} b Second number
|
|
958
|
-
* @returns {Number}
|
|
960
|
+
* @param {Number} a First number, not zero, Infinity, or NaN
|
|
961
|
+
* @param {Number} b Second number, not zero, Infinity, or NaN
|
|
962
|
+
* @returns {Number} gcd(a, b) if a and b are finite, non-zero numbers, NaN else.
|
|
963
|
+
* @see JXG.Math#lcm
|
|
959
964
|
*/
|
|
960
965
|
gcd: function (a, b) {
|
|
961
966
|
var tmp,
|
|
962
|
-
endless =
|
|
967
|
+
endless = 100000;
|
|
963
968
|
|
|
964
969
|
a = Math.abs(a);
|
|
965
970
|
b = Math.abs(b);
|
|
@@ -967,13 +972,24 @@ JXG.Math = {
|
|
|
967
972
|
if (!(Type.isNumber(a) && Type.isNumber(b))) {
|
|
968
973
|
return NaN;
|
|
969
974
|
}
|
|
975
|
+
if (isNaN(a) || isNaN(b) || a === Infinity || b === Infinity) {
|
|
976
|
+
return NaN;
|
|
977
|
+
}
|
|
978
|
+
if (a === 0 || b === 0) {
|
|
979
|
+
return NaN;
|
|
980
|
+
}
|
|
981
|
+
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
982
|
+
JXG.warn('JSXGraph: JXG.Math.gcd requires integer parameters');
|
|
983
|
+
return NaN;
|
|
984
|
+
}
|
|
985
|
+
|
|
970
986
|
if (b > a) {
|
|
971
987
|
tmp = a;
|
|
972
988
|
a = b;
|
|
973
989
|
b = tmp;
|
|
974
990
|
}
|
|
975
991
|
|
|
976
|
-
while (endless) {
|
|
992
|
+
while (endless > 0) {
|
|
977
993
|
a %= b;
|
|
978
994
|
if (a === 0) {
|
|
979
995
|
return b;
|
|
@@ -982,15 +998,18 @@ JXG.Math = {
|
|
|
982
998
|
if (b === 0) {
|
|
983
999
|
return a;
|
|
984
1000
|
}
|
|
1001
|
+
endless--;
|
|
985
1002
|
}
|
|
986
1003
|
},
|
|
987
1004
|
|
|
988
1005
|
/**
|
|
989
|
-
* Least common multiple (lcm) of two numbers.
|
|
1006
|
+
* Least common multiple (lcm) of two finite integer numbers.
|
|
1007
|
+
* lcm(0, a) is defined as 0.
|
|
990
1008
|
*
|
|
991
1009
|
* @param {Number} a First number
|
|
992
1010
|
* @param {Number} b Second number
|
|
993
|
-
* @returns {Number}
|
|
1011
|
+
* @returns {Number} lcm(a, b) if a and b are finite integer numbers, NaN else.
|
|
1012
|
+
* @see JXG.Math#gcd
|
|
994
1013
|
*/
|
|
995
1014
|
lcm: function (a, b) {
|
|
996
1015
|
var ret;
|
|
@@ -998,6 +1017,16 @@ JXG.Math = {
|
|
|
998
1017
|
if (!(Type.isNumber(a) && Type.isNumber(b))) {
|
|
999
1018
|
return NaN;
|
|
1000
1019
|
}
|
|
1020
|
+
if (isNaN(a) || isNaN(b) || Math.abs(a) === Infinity || Math.abs(b) === Infinity) {
|
|
1021
|
+
return NaN;
|
|
1022
|
+
}
|
|
1023
|
+
if (a === 0 || b === 0) {
|
|
1024
|
+
return 0;
|
|
1025
|
+
}
|
|
1026
|
+
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
1027
|
+
JXG.warn('JSXGraph: JXG.Math.gcd requires integer parameters');
|
|
1028
|
+
return NaN;
|
|
1029
|
+
}
|
|
1001
1030
|
|
|
1002
1031
|
ret = a * b;
|
|
1003
1032
|
if (ret !== 0) {
|
|
@@ -1183,7 +1212,7 @@ JXG.Math = {
|
|
|
1183
1212
|
/* ******************** Comparisons and logical operators ************** */
|
|
1184
1213
|
|
|
1185
1214
|
/**
|
|
1186
|
-
* Logical test: a < b
|
|
1215
|
+
* Logical test: `a < b`?
|
|
1187
1216
|
*
|
|
1188
1217
|
* @param {Number} a
|
|
1189
1218
|
* @param {Number} b
|
|
@@ -1194,7 +1223,7 @@ JXG.Math = {
|
|
|
1194
1223
|
},
|
|
1195
1224
|
|
|
1196
1225
|
/**
|
|
1197
|
-
* Logical test: a <= b
|
|
1226
|
+
* Logical test: `a <= b`?
|
|
1198
1227
|
*
|
|
1199
1228
|
* @param {Number} a
|
|
1200
1229
|
* @param {Number} b
|
|
@@ -1205,7 +1234,7 @@ JXG.Math = {
|
|
|
1205
1234
|
},
|
|
1206
1235
|
|
|
1207
1236
|
/**
|
|
1208
|
-
* Logical test: a > b
|
|
1237
|
+
* Logical test: `a > b`?
|
|
1209
1238
|
*
|
|
1210
1239
|
* @param {Number} a
|
|
1211
1240
|
* @param {Number} b
|
|
@@ -1216,7 +1245,7 @@ JXG.Math = {
|
|
|
1216
1245
|
},
|
|
1217
1246
|
|
|
1218
1247
|
/**
|
|
1219
|
-
* Logical test: a >= b
|
|
1248
|
+
* Logical test: `a >= b`?
|
|
1220
1249
|
*
|
|
1221
1250
|
* @param {Number} a
|
|
1222
1251
|
* @param {Number} b
|
|
@@ -1227,7 +1256,7 @@ JXG.Math = {
|
|
|
1227
1256
|
},
|
|
1228
1257
|
|
|
1229
1258
|
/**
|
|
1230
|
-
* Logical test: a === b
|
|
1259
|
+
* Logical test: `a === b`?
|
|
1231
1260
|
*
|
|
1232
1261
|
* @param {Number} a
|
|
1233
1262
|
* @param {Number} b
|
|
@@ -1238,7 +1267,7 @@ JXG.Math = {
|
|
|
1238
1267
|
},
|
|
1239
1268
|
|
|
1240
1269
|
/**
|
|
1241
|
-
* Logical test: a !== b
|
|
1270
|
+
* Logical test: `a !== b`?
|
|
1242
1271
|
*
|
|
1243
1272
|
* @param {Number} a
|
|
1244
1273
|
* @param {Number} b
|
|
@@ -1249,7 +1278,7 @@ JXG.Math = {
|
|
|
1249
1278
|
},
|
|
1250
1279
|
|
|
1251
1280
|
/**
|
|
1252
|
-
* Logical operator: a && b
|
|
1281
|
+
* Logical operator: `a && b`?
|
|
1253
1282
|
*
|
|
1254
1283
|
* @param {Boolean} a
|
|
1255
1284
|
* @param {Boolean} b
|
|
@@ -1260,7 +1289,7 @@ JXG.Math = {
|
|
|
1260
1289
|
},
|
|
1261
1290
|
|
|
1262
1291
|
/**
|
|
1263
|
-
* Logical operator:
|
|
1292
|
+
* Logical operator: `!a`?
|
|
1264
1293
|
*
|
|
1265
1294
|
* @param {Boolean} a
|
|
1266
1295
|
* @returns {Boolean}
|
|
@@ -1270,7 +1299,7 @@ JXG.Math = {
|
|
|
1270
1299
|
},
|
|
1271
1300
|
|
|
1272
1301
|
/**
|
|
1273
|
-
* Logical operator: a || b
|
|
1302
|
+
* Logical operator: `a || b`?
|
|
1274
1303
|
*
|
|
1275
1304
|
* @param {Boolean} a
|
|
1276
1305
|
* @param {Boolean} b
|
|
@@ -1281,7 +1310,7 @@ JXG.Math = {
|
|
|
1281
1310
|
},
|
|
1282
1311
|
|
|
1283
1312
|
/**
|
|
1284
|
-
* Logical operator: either a or b
|
|
1313
|
+
* Logical operator: either `a` or `b`?
|
|
1285
1314
|
*
|
|
1286
1315
|
* @param {Boolean} a
|
|
1287
1316
|
* @param {Boolean} b
|
|
@@ -1360,7 +1389,7 @@ JXG.Math = {
|
|
|
1360
1389
|
/* *************************** Normalize *************************** */
|
|
1361
1390
|
|
|
1362
1391
|
/**
|
|
1363
|
-
* Normalize the standard form [c, b0, b1, a, k, r, q0, q1]
|
|
1392
|
+
* Normalize the standard form `[c, b0, b1, a, k, r, q0, q1]`.
|
|
1364
1393
|
* @private
|
|
1365
1394
|
* @param {Array} stdform The standard form to be normalized.
|
|
1366
1395
|
* @returns {Array} The normalized standard form.
|
|
@@ -1431,13 +1460,13 @@ JXG.Math = {
|
|
|
1431
1460
|
},
|
|
1432
1461
|
|
|
1433
1462
|
/**
|
|
1434
|
-
* Theorem of Vieta: Given a set of simple zeroes x_0,
|
|
1435
|
-
* of a polynomial f, compute the coefficients s_k, (k=0
|
|
1436
|
-
* of the polynomial of the form
|
|
1463
|
+
* Theorem of Vieta: Given a set of simple zeroes \\(x_0, \ldots, x_n\\)
|
|
1464
|
+
* of a polynomial \\(f\\), compute the coefficients \\(s_k\\), \\(k=0, \ldots, n-1\\),
|
|
1465
|
+
* of the polynomial of the form
|
|
1466
|
+
* \\[ f(x) = (x-x_0)\cdots(x-x_n) = x^n + \sum_{k=1}^{n} (-1)^k s_{k-1} x^{n-k} \\]
|
|
1467
|
+
*
|
|
1468
|
+
* See {@link https://en.wikipedia.org/wiki/Vieta%27s_formulas}
|
|
1437
1469
|
*
|
|
1438
|
-
* f(x) = (x-x_0)*...*(x-x_n) =
|
|
1439
|
-
* x^n + sum_{k=1}^{n} (-1)^(k) s_{k-1} x^(n-k)
|
|
1440
|
-
* </p>
|
|
1441
1470
|
* @param {Array} x Simple zeroes of the polynomial.
|
|
1442
1471
|
* @returns {Array} Coefficients of the polynomial.
|
|
1443
1472
|
*
|
package/src/math/numerics.js
CHANGED
|
@@ -509,22 +509,20 @@ Mat.Numerics = {
|
|
|
509
509
|
* Calculates the integral of function f over interval using Romberg iteration.
|
|
510
510
|
* @param {Array} interval The integration interval, e.g. [0, 3].
|
|
511
511
|
* @param {function} f A function which takes one argument of type number and returns a number.
|
|
512
|
-
* @param {Object} [config] The algorithm setup. Accepted properties are max_iterations of type number and precision eps
|
|
512
|
+
* @param {Object} [config] The algorithm setup. Accepted properties are `max_iterations` of type number and precision `eps`.
|
|
513
513
|
* @param {Number} [config.max_iterations=20]
|
|
514
514
|
* @param {Number} [config.eps=0.0000001]
|
|
515
515
|
* @returns {Number} Integral value of f over interval
|
|
516
516
|
* @example
|
|
517
|
-
*
|
|
518
|
-
* return x*x;
|
|
519
|
-
* }
|
|
517
|
+
* var f = (x) => x * x;
|
|
520
518
|
*
|
|
521
|
-
* //
|
|
522
|
-
* var area1 = JXG.Math.Numerics.Romberg([0,
|
|
519
|
+
* // Calculates integral of `f` from 0 to 3.
|
|
520
|
+
* var area1 = JXG.Math.Numerics.Romberg([0, 3], f);
|
|
523
521
|
*
|
|
524
|
-
* //
|
|
525
|
-
* var area2 = JXG.Math.Numerics.Romberg([0,
|
|
522
|
+
* // The same with an anonymous function
|
|
523
|
+
* var area2 = JXG.Math.Numerics.Romberg([0, 3], function (x) { return x * x; });
|
|
526
524
|
*
|
|
527
|
-
* //
|
|
525
|
+
* // Use trapez rule with maximum of 16 iterations or stop if the precision 0.0001 has been reached.
|
|
528
526
|
* var area3 = JXG.Math.Numerics.Romberg([0, 2], f,
|
|
529
527
|
* {max_iterations: 16, eps: 0.0001});
|
|
530
528
|
* @memberof JXG.Math.Numerics
|
|
@@ -541,8 +539,11 @@ Mat.Numerics = {
|
|
|
541
539
|
p = [],
|
|
542
540
|
integral = 0.0,
|
|
543
541
|
last = Infinity,
|
|
544
|
-
m
|
|
545
|
-
|
|
542
|
+
m, eps;
|
|
543
|
+
|
|
544
|
+
config = Type.def(config, {});
|
|
545
|
+
m = config && Type.isNumber(config.max_iterations) ? config.max_iterations : 20;
|
|
546
|
+
eps = config && Type.isNumber(config.eps) ? config.eps : (config.eps || 0.0000001);
|
|
546
547
|
|
|
547
548
|
a = interval[0];
|
|
548
549
|
b = interval[1];
|
|
@@ -809,7 +810,7 @@ Mat.Numerics = {
|
|
|
809
810
|
xm = 0.5 * (b - a);
|
|
810
811
|
xp = 0.5 * (b + a);
|
|
811
812
|
|
|
812
|
-
if (n &
|
|
813
|
+
if ((n & 1) === 1) {
|
|
813
814
|
// n odd
|
|
814
815
|
result = w[0] * f(xp);
|
|
815
816
|
for (i = 1; i < m; ++i) {
|
package/src/math/statistics.js
CHANGED
|
@@ -619,12 +619,12 @@ Mat.Statistics = {
|
|
|
619
619
|
* The Theil-Sen estimator can be used to determine a more robust linear regression of a set of sample
|
|
620
620
|
* points than least squares regression in {@link JXG.Math.Numerics.regressionPolynomial}.
|
|
621
621
|
*
|
|
622
|
-
* If the function should be applied to an array a of points
|
|
623
|
-
* JavaScript array.map
|
|
622
|
+
* If the function should be applied to an array `a` of *points*, a coords array can be generated with
|
|
623
|
+
* JavaScript `array.map`:
|
|
624
624
|
*
|
|
625
|
-
*
|
|
625
|
+
* ```
|
|
626
626
|
* JXG.Math.Statistics.TheilSenRegression(a.map(el => el.coords));
|
|
627
|
-
*
|
|
627
|
+
* ```
|
|
628
628
|
*
|
|
629
629
|
* @param {Array} coords Array of {@link JXG.Coords}.
|
|
630
630
|
* @returns {Array} A stdform array of the regression line.
|
|
@@ -632,10 +632,10 @@ Mat.Statistics = {
|
|
|
632
632
|
*
|
|
633
633
|
* @example
|
|
634
634
|
* var board = JXG.JSXGraph.initBoard('jxgbox', { boundingbox: [-6,6,6,-6], axis : true });
|
|
635
|
-
* var a=[];
|
|
636
|
-
* a[0]=board.create('point', [0,0]);
|
|
637
|
-
* a[1]=board.create('point', [3,0]);
|
|
638
|
-
* a[2]=board.create('point', [0,3]);
|
|
635
|
+
* var a = [];
|
|
636
|
+
* a[0] = board.create('point', [0, 0]);
|
|
637
|
+
* a[1] = board.create('point', [3, 0]);
|
|
638
|
+
* a[2] = board.create('point', [0, 3]);
|
|
639
639
|
*
|
|
640
640
|
* board.create('line', [
|
|
641
641
|
* () => JXG.Math.Statistics.TheilSenRegression(a.map(el => el.coords))
|
|
@@ -689,7 +689,7 @@ Mat.Statistics = {
|
|
|
689
689
|
|
|
690
690
|
/**
|
|
691
691
|
* Generate values of a standard normal random variable with the Marsaglia polar method, see
|
|
692
|
-
*
|
|
692
|
+
* {@link https://en.wikipedia.org/wiki/Marsaglia_polar_method}..
|
|
693
693
|
* See also D. E. Knuth, The art of computer programming, vol 2, p. 117.
|
|
694
694
|
*
|
|
695
695
|
* @param {Number} mean mean value of the normal distribution
|
|
@@ -779,7 +779,7 @@ Mat.Statistics = {
|
|
|
779
779
|
},
|
|
780
780
|
|
|
781
781
|
/**
|
|
782
|
-
* Generate value of a uniform distributed random variable in the interval [a, b]
|
|
782
|
+
* Generate value of a uniform distributed random variable in the interval `[a, b]`.
|
|
783
783
|
* @param {Number} a
|
|
784
784
|
* @param {Number} b
|
|
785
785
|
* @returns Number
|
|
@@ -791,7 +791,7 @@ Mat.Statistics = {
|
|
|
791
791
|
|
|
792
792
|
/**
|
|
793
793
|
* Generate value of a random variable with exponential distribution, i.e.
|
|
794
|
-
* \\(f(x; \lambda) = \lambda
|
|
794
|
+
* \\(f(x; \lambda) = \lambda \cdot e^{-\lambda x}\\) if \\(x \geq 0\\) and \\(f(x; \lambda) = 0\\) if \\(x < 0\\).
|
|
795
795
|
* See <a href="https://en.wikipedia.org/wiki/Exponential_distribution">https://en.wikipedia.org/wiki/Exponential_distribution</a>.
|
|
796
796
|
* Algorithm: D.E. Knuth, TAOCP 2, p. 128.
|
|
797
797
|
*
|
|
@@ -860,7 +860,7 @@ Mat.Statistics = {
|
|
|
860
860
|
|
|
861
861
|
/**
|
|
862
862
|
* Generate value of a random variable with gamma distribution of order alpha.
|
|
863
|
-
* See
|
|
863
|
+
* See {@link https://en.wikipedia.org/wiki/Gamma_distribution}.
|
|
864
864
|
* Algorithm: D.E. Knuth, TAOCP 2, p. 129.
|
|
865
865
|
|
|
866
866
|
* @param {Number} a shape, \\( > 0\\)
|
|
@@ -976,7 +976,7 @@ Mat.Statistics = {
|
|
|
976
976
|
|
|
977
977
|
/**
|
|
978
978
|
* Generate value of a random variable with beta distribution with shape parameters alpha and beta.
|
|
979
|
-
* See
|
|
979
|
+
* See {@link https://en.wikipedia.org/wiki/Beta_distribution}.
|
|
980
980
|
*
|
|
981
981
|
* @param {Number} alpha \\(< 0\\)
|
|
982
982
|
* @param {Number} beta \\(< 0\\)
|
|
@@ -999,7 +999,7 @@ Mat.Statistics = {
|
|
|
999
999
|
|
|
1000
1000
|
/**
|
|
1001
1001
|
* Generate value of a random variable with chi-square distribution with k degrees of freedom.
|
|
1002
|
-
* See
|
|
1002
|
+
* See {@link https://en.wikipedia.org/wiki/Chi-squared_distribution}.
|
|
1003
1003
|
*
|
|
1004
1004
|
* @param {Number} k \\(>0\\)
|
|
1005
1005
|
* @returns Number
|
|
@@ -1017,7 +1017,7 @@ Mat.Statistics = {
|
|
|
1017
1017
|
|
|
1018
1018
|
/**
|
|
1019
1019
|
* Generate value of a random variable with F-distribution with d<sub>1</sub> and d<sub>2</sub> degrees of freedom.
|
|
1020
|
-
* See
|
|
1020
|
+
* See {@link https://en.wikipedia.org/wiki/F-distribution}.
|
|
1021
1021
|
* @param {Number} d1 \\(>0\\)
|
|
1022
1022
|
* @param {Number} d2 \\(>0\\)
|
|
1023
1023
|
* @returns Number
|
|
@@ -1039,7 +1039,7 @@ Mat.Statistics = {
|
|
|
1039
1039
|
|
|
1040
1040
|
/**
|
|
1041
1041
|
* Generate value of a random variable with Students-t-distribution with ν degrees of freedom.
|
|
1042
|
-
* See
|
|
1042
|
+
* See {@link https://en.wikipedia.org/wiki/Student%27s_t-distribution}.
|
|
1043
1043
|
* @param {Number} nu \\(>0\\)
|
|
1044
1044
|
* @returns Number
|
|
1045
1045
|
* @memberof JXG.Math.Statistics
|
|
@@ -1060,8 +1060,8 @@ Mat.Statistics = {
|
|
|
1060
1060
|
|
|
1061
1061
|
/**
|
|
1062
1062
|
* Generate values for a random variable in binomial distribution with parameters \\(n\\) and \\(p\\).
|
|
1063
|
-
* See
|
|
1064
|
-
* It uses algorithm BG from
|
|
1063
|
+
* See {@link https://en.wikipedia.org/wiki/Binomial_distribution}.
|
|
1064
|
+
* It uses algorithm BG from {@link https://dl.acm.org/doi/pdf/10.1145/42372.42381}.
|
|
1065
1065
|
*
|
|
1066
1066
|
* @param {Number} n Number of trials (n >= 0)
|
|
1067
1067
|
* @param {Number} p Probability (0 <= p <= 1)
|
|
@@ -1185,7 +1185,7 @@ Mat.Statistics = {
|
|
|
1185
1185
|
|
|
1186
1186
|
/**
|
|
1187
1187
|
* Generate values for a random variable in geometric distribution with probability \\(p\\).
|
|
1188
|
-
* See
|
|
1188
|
+
* See {@link https://en.wikipedia.org/wiki/Geometric_distribution}.
|
|
1189
1189
|
*
|
|
1190
1190
|
* @param {Number} p (0 <= p <= 1)
|
|
1191
1191
|
* @returns Number
|