math-exercises 2.2.90 → 2.2.91
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/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +13 -6
- package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.js +68 -68
- package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.js +59 -22
- package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.js +65 -34
- package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.js +54 -22
- package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.js +35 -15
- package/lib/exercises/math/calculLitteral/equation/firstDegreeEquation.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/firstDegreeEquation.js +51 -29
- package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.js +48 -21
- package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.js +44 -22
- package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.js +22 -8
- package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +27 -16
- package/lib/exercises/math/combinatory/ballsCounting.d.ts.map +1 -1
- package/lib/exercises/math/combinatory/ballsCounting.js +44 -18
- package/lib/exercises/math/functions/affines/affineAdjustment.d.ts +0 -4
- package/lib/exercises/math/functions/affines/affineAdjustment.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineAdjustment.js +27 -27
- package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts +0 -5
- package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineAdjustmentComplete.js +45 -62
- package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts +0 -1
- package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.js +32 -48
- package/lib/exercises/math/matrices/productCell.js +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/interquartilesList.js +1 -1
- package/lib/exercises/math/probaStat/stats1var/interquartilesTable.js +1 -1
- package/lib/exercises/math/probaStat/stats1var/standardDeviationList.js +2 -2
- package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.js +2 -2
- package/lib/exercises/math/probaStat/stats1var/varianceList.js +1 -1
- package/lib/exercises/math/probaStat/stats1var/varianceTable.js +1 -1
- package/lib/index.d.ts +0 -10
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/CloudPoints.js +2 -2
- package/lib/math/probability/binomial.js +1 -1
- package/lib/math/utils/round.d.ts.map +1 -1
- package/lib/math/utils/round.js +19 -5
- package/lib/math/utils/stats/covariance.d.ts +4 -0
- package/lib/math/utils/stats/covariance.d.ts.map +1 -0
- package/lib/math/utils/stats/covariance.js +26 -0
- package/lib/math/utils/stats/generateAffineCloud.d.ts +5 -0
- package/lib/math/utils/stats/generateAffineCloud.d.ts.map +1 -0
- package/lib/math/utils/stats/generateAffineCloud.js +23 -0
- package/lib/math/utils/stats/leastSquares.d.ts +5 -0
- package/lib/math/utils/stats/leastSquares.d.ts.map +1 -0
- package/lib/math/utils/stats/leastSquares.js +19 -0
- package/lib/math/utils/stats/quartiles.d.ts +3 -0
- package/lib/math/utils/stats/quartiles.d.ts.map +1 -0
- package/lib/math/utils/stats/quartiles.js +47 -0
- package/lib/math/utils/stats/rSquared.d.ts +2 -0
- package/lib/math/utils/stats/rSquared.d.ts.map +1 -0
- package/lib/math/utils/stats/rSquared.js +17 -0
- package/lib/math/utils/stats/standardDeviation.d.ts +3 -0
- package/lib/math/utils/stats/standardDeviation.d.ts.map +1 -0
- package/lib/math/utils/stats/standardDeviation.js +13 -0
- package/lib/math/utils/stats/sum.d.ts +8 -0
- package/lib/math/utils/stats/sum.d.ts.map +1 -0
- package/lib/math/utils/stats/sum.js +17 -0
- package/lib/math/utils/stats/variance.d.ts +5 -0
- package/lib/math/utils/stats/variance.d.ts.map +1 -0
- package/lib/math/utils/stats/variance.js +35 -0
- package/lib/playground.d.ts.map +1 -1
- package/lib/tree/nodes/operators/limitNode.d.ts +1 -1
- package/lib/tree/parsers/discreteSetParser.d.ts.map +1 -1
- package/lib/tree/parsers/discreteSetParser.js +3 -0
- package/package.json +1 -1
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.affineAdjustmentExercise = void 0;
|
|
4
4
|
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const randfloat_1 = require("../../../../math/utils/random/randfloat");
|
|
6
7
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
7
8
|
const round_1 = require("../../../../math/utils/round");
|
|
9
|
+
const leastSquares_1 = require("../../../../math/utils/stats/leastSquares");
|
|
8
10
|
const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
|
|
9
11
|
const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
|
|
10
12
|
const addNode_1 = require("../../../../tree/nodes/operators/addNode");
|
|
@@ -41,23 +43,22 @@ function generateLinearData(n) {
|
|
|
41
43
|
}
|
|
42
44
|
return data;
|
|
43
45
|
}
|
|
46
|
+
const getAnswer = (identifiers) => {
|
|
47
|
+
const { xValues, yValues } = identifiers;
|
|
48
|
+
const { a, b } = (0, leastSquares_1.leastSquares)(xValues, yValues);
|
|
49
|
+
const aFixed = (0, round_1.round)(a, 1);
|
|
50
|
+
const bFixed = (0, round_1.round)(b, 1);
|
|
51
|
+
const answer = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(aFixed), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
|
|
52
|
+
return answer;
|
|
53
|
+
};
|
|
44
54
|
const getAffineAdjustmentQuestion = () => {
|
|
45
55
|
const data = generateLinearData(6);
|
|
46
56
|
data.sort((a, b) => a.x - b.x);
|
|
47
57
|
const xValues = data.map((point) => point.x);
|
|
48
58
|
const yValues = data.map((point) => point.y);
|
|
49
|
-
const
|
|
50
|
-
const G2x = (0, round_1.round)((xValues[3] + xValues[4] + xValues[5]) / 3, 1);
|
|
51
|
-
const G1y = (0, round_1.round)((yValues[0] + yValues[1] + yValues[2]) / 3, 1);
|
|
52
|
-
const G2y = (0, round_1.round)((yValues[3] + yValues[4] + yValues[5]) / 3, 1);
|
|
53
|
-
const a = (G2y - G1y) / (G2x - G1x);
|
|
54
|
-
const afixed = (0, round_1.round)(a, 1);
|
|
55
|
-
const b = G2y - a * G2x;
|
|
56
|
-
const bfixed = (0, round_1.round)(b, 1);
|
|
57
|
-
const answer = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(afixed), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(bfixed)).simplify({ forbidFactorize: true })).toTex();
|
|
58
|
-
const identifiers = { G1x, G2x, G1y, G2y, xValues, yValues };
|
|
59
|
+
const identifiers = { xValues, yValues };
|
|
59
60
|
const question = {
|
|
60
|
-
answer:
|
|
61
|
+
answer: getAnswer(identifiers),
|
|
61
62
|
instruction: getInstruction(identifiers),
|
|
62
63
|
keys: ["equal", "y", "x", "a", "b"],
|
|
63
64
|
answerFormat: "tex",
|
|
@@ -66,18 +67,17 @@ const getAffineAdjustmentQuestion = () => {
|
|
|
66
67
|
};
|
|
67
68
|
return question;
|
|
68
69
|
};
|
|
69
|
-
const getPropositions = (n, { answer,
|
|
70
|
+
const getPropositions = (n, { answer, xValues, yValues }) => {
|
|
70
71
|
const propositions = [];
|
|
71
72
|
(0, exercise_1.addValidProp)(propositions, answer, "tex");
|
|
72
|
-
const a = (
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const wrongAnswer3 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(afixed), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode((0, round_1.round)(bwrong, 1))).simplify({ forbidFactorize: true }));
|
|
73
|
+
const { a, b } = (0, leastSquares_1.leastSquares)(xValues, yValues);
|
|
74
|
+
const aFixed = (0, round_1.round)(a, 1);
|
|
75
|
+
const bFixed = (0, round_1.round)(b, 1);
|
|
76
|
+
const wrongAnswer1 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new substractNode_1.SubstractNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(aFixed), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(bFixed)).simplify({ forbidFactorize: true }));
|
|
77
|
+
const awrong = (0, randfloat_1.randfloat)(-5, 5, 1, [0]);
|
|
78
|
+
const bwrong = (0, randfloat_1.randfloat)(-20, 20, 1);
|
|
79
|
+
const wrongAnswer2 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode((0, round_1.round)(awrong, 1)), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(bFixed)).simplify({ forbidFactorize: true }));
|
|
80
|
+
const wrongAnswer3 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(aFixed), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode((0, round_1.round)(bwrong, 1))).simplify({ forbidFactorize: true }));
|
|
81
81
|
const wrongAnswer4 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode((0, round_1.round)(awrong, 1)), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode((0, round_1.round)(bwrong, 1))).simplify({ forbidFactorize: true }));
|
|
82
82
|
(0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer1.toTex());
|
|
83
83
|
(0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer2.toTex());
|
|
@@ -91,12 +91,11 @@ const getPropositions = (n, { answer, G1x, G2x, G1y, G2y }) => {
|
|
|
91
91
|
}
|
|
92
92
|
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
93
93
|
};
|
|
94
|
-
const isAnswerValid = (ans, {
|
|
95
|
-
const a = (
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const valid = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(afixed), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(bfixed)).simplify({ forbidFactorize: true }));
|
|
94
|
+
const isAnswerValid = (ans, { answer, xValues, yValues }) => {
|
|
95
|
+
const { a, b } = (0, leastSquares_1.leastSquares)(xValues, yValues);
|
|
96
|
+
const aFixed = (0, round_1.round)(a, 1);
|
|
97
|
+
const bFixed = (0, round_1.round)(b, 1);
|
|
98
|
+
const valid = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(aFixed), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(bFixed)).simplify({ forbidFactorize: true }));
|
|
100
99
|
const latexs = valid.toAllValidTexs({ allowRawRightChildAsSolution: true });
|
|
101
100
|
return latexs.includes(ans);
|
|
102
101
|
};
|
|
@@ -113,4 +112,5 @@ exports.affineAdjustmentExercise = {
|
|
|
113
112
|
isAnswerValid,
|
|
114
113
|
subject: "Mathématiques",
|
|
115
114
|
getInstruction,
|
|
115
|
+
getAnswer,
|
|
116
116
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affineAdjustmentComplete.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineAdjustmentComplete.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"affineAdjustmentComplete.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineAdjustmentComplete.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAqBlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAoJF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAiBlE,CAAC"}
|
|
@@ -3,8 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.affineAdjustmentCompleteExercise = void 0;
|
|
4
4
|
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const randfloat_1 = require("../../../../math/utils/random/randfloat");
|
|
6
7
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
7
8
|
const round_1 = require("../../../../math/utils/round");
|
|
9
|
+
const generateAffineCloud_1 = require("../../../../math/utils/stats/generateAffineCloud");
|
|
10
|
+
const leastSquares_1 = require("../../../../math/utils/stats/leastSquares");
|
|
11
|
+
const rSquared_1 = require("../../../../math/utils/stats/rSquared");
|
|
8
12
|
const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
|
|
9
13
|
const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
|
|
10
14
|
const addNode_1 = require("../../../../tree/nodes/operators/addNode");
|
|
@@ -14,81 +18,58 @@ const substractNode_1 = require("../../../../tree/nodes/operators/substractNode"
|
|
|
14
18
|
const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
|
|
15
19
|
const dollarize_1 = require("../../../../utils/latex/dollarize");
|
|
16
20
|
const mdTable_1 = require("../../../../utils/markdown/mdTable");
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const sumX = xValues.reduce((acc, x) => acc + x, 0);
|
|
37
|
-
const sumY = yValues.reduce((acc, y) => acc + y, 0);
|
|
38
|
-
const sumXY = xValues.reduce((acc, x, i) => acc + x * yValues[i], 0);
|
|
39
|
-
const sumX2 = xValues.reduce((acc, x) => acc + x * x, 0);
|
|
40
|
-
const sumY2 = yValues.reduce((acc, y) => acc + y * y, 0);
|
|
41
|
-
const numerator = n * sumXY - sumX * sumY;
|
|
42
|
-
const denominator = Math.sqrt((n * sumX2 - sumX * sumX) * (n * sumY2 - sumY * sumY));
|
|
43
|
-
const r = numerator / denominator;
|
|
44
|
-
const rSquared = r * r;
|
|
45
|
-
return (0, round_1.round)(rSquared, 2);
|
|
46
|
-
}
|
|
21
|
+
const getAnswer = (identifiers) => {
|
|
22
|
+
const { xValues, yValues } = identifiers;
|
|
23
|
+
const { a, b } = (0, leastSquares_1.leastSquares)(xValues, yValues);
|
|
24
|
+
const aFixed = (0, round_1.round)(a, 1);
|
|
25
|
+
const bFixed = (0, round_1.round)(b, 1);
|
|
26
|
+
const answerEq = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(aFixed), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
|
|
27
|
+
const r2 = (0, round_1.round)((0, rSquared_1.rSquared)(xValues, yValues), 2);
|
|
28
|
+
const answerR = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), r2.toTree()).toTex();
|
|
29
|
+
return `${answerEq}\\newline ${answerR}`;
|
|
30
|
+
};
|
|
31
|
+
const getInstruction = (identifiers) => {
|
|
32
|
+
const { xValues, yValues } = identifiers;
|
|
33
|
+
const dataTable = (0, mdTable_1.mdTable)([
|
|
34
|
+
["$x$", ...xValues.map((n) => (0, dollarize_1.dollarize)(n.frenchify()))],
|
|
35
|
+
["$y$", ...yValues.map((n) => (0, dollarize_1.dollarize)(n.frenchify()))],
|
|
36
|
+
]);
|
|
37
|
+
return `On considère la série statistique ci-dessous. A l'aide de la calculatrice, déterminer l'équation de la droite d'ajustement et la valeur du coefficient de détermination. ${dataTable}
|
|
38
|
+
`;
|
|
39
|
+
};
|
|
47
40
|
const getAffineAdjustmentCompleteQuestion = () => {
|
|
48
|
-
const data =
|
|
41
|
+
const data = (0, generateAffineCloud_1.generateAffineCloud)(6);
|
|
49
42
|
data.sort((a, b) => a.x - b.x);
|
|
50
43
|
const xValues = data.map((point) => point.x);
|
|
51
44
|
const yValues = data.map((point) => point.y);
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const rSquared = calculateRSquared(xValues, yValues);
|
|
57
|
-
const a = (G2y - G1y) / (G2x - G1x);
|
|
58
|
-
const afixed = (0, round_1.round)(a, 1);
|
|
59
|
-
const b = G2y - a * G2x;
|
|
60
|
-
const bfixed = (0, round_1.round)(b, 1);
|
|
61
|
-
const answerEq = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(afixed), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(bfixed)).simplify({ forbidFactorize: true })).toTex();
|
|
62
|
-
const answerR = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), rSquared.toTree()).toTex();
|
|
63
|
-
let dataTable = (0, mdTable_1.mdTable)([
|
|
64
|
-
["$x$", ...xValues.map((n) => (0, dollarize_1.dollarize)(n.frenchify()))],
|
|
65
|
-
["$y$", ...yValues.map((n) => (0, dollarize_1.dollarize)(n.frenchify()))],
|
|
66
|
-
]);
|
|
45
|
+
const identifiers = {
|
|
46
|
+
xValues,
|
|
47
|
+
yValues,
|
|
48
|
+
};
|
|
67
49
|
const question = {
|
|
68
|
-
answer:
|
|
69
|
-
instruction:
|
|
70
|
-
`,
|
|
50
|
+
answer: getAnswer(identifiers),
|
|
51
|
+
instruction: getInstruction(identifiers),
|
|
71
52
|
keys: [],
|
|
72
53
|
answerFormat: "tex",
|
|
73
|
-
identifiers
|
|
54
|
+
identifiers,
|
|
74
55
|
style: { tableHasNoHeader: true },
|
|
75
56
|
};
|
|
76
57
|
return question;
|
|
77
58
|
};
|
|
78
|
-
const getPropositions = (n, { answer,
|
|
59
|
+
const getPropositions = (n, { answer, xValues, yValues }) => {
|
|
79
60
|
const propositions = [];
|
|
80
61
|
(0, exercise_1.addValidProp)(propositions, answer, "tex");
|
|
81
|
-
const a = (
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
const answerEq = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(
|
|
86
|
-
const answerR = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)),
|
|
87
|
-
const wrongAnswerEq1 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new substractNode_1.SubstractNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(
|
|
88
|
-
const awrong = (
|
|
89
|
-
const wrongAnswerEq2 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode((0, round_1.round)(awrong, 1)), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(
|
|
90
|
-
const wrongAnswerR1 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("R"),
|
|
91
|
-
const wrongAnswerR2 = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), (
|
|
62
|
+
const { a, b } = (0, leastSquares_1.leastSquares)(xValues, yValues);
|
|
63
|
+
const r2 = (0, round_1.round)((0, rSquared_1.rSquared)(xValues, yValues), 2);
|
|
64
|
+
const aFixed = (0, round_1.round)(a, 1);
|
|
65
|
+
const bFixed = (0, round_1.round)(b, 1);
|
|
66
|
+
const answerEq = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(aFixed), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
|
|
67
|
+
const answerR = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), r2.toTree()).toTex();
|
|
68
|
+
const wrongAnswerEq1 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new substractNode_1.SubstractNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(aFixed), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
|
|
69
|
+
const awrong = (0, randfloat_1.randfloat)(1, 10, 1);
|
|
70
|
+
const wrongAnswerEq2 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("y"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode((0, round_1.round)(awrong, 1)), new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
|
|
71
|
+
const wrongAnswerR1 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("R"), r2.toTree()).toTex();
|
|
72
|
+
const wrongAnswerR2 = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), (r2 + 0.01).toTree()).toTex();
|
|
92
73
|
const wrongAnswer1 = `${answerEq}\\newline ${wrongAnswerR1}`;
|
|
93
74
|
const wrongAnswer2 = `${answerEq}\\newline ${wrongAnswerR2}`;
|
|
94
75
|
const wrongAnswer3 = `${wrongAnswerEq1}\\newline ${answerR}`;
|
|
@@ -123,4 +104,6 @@ exports.affineAdjustmentCompleteExercise = {
|
|
|
123
104
|
getPropositions,
|
|
124
105
|
isAnswerValid,
|
|
125
106
|
subject: "Mathématiques",
|
|
107
|
+
getAnswer,
|
|
108
|
+
getInstruction,
|
|
126
109
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affineAdjustmentRsquared.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineAdjustmentRsquared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"affineAdjustmentRsquared.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineAdjustmentRsquared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAmBlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAqGF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAgBlE,CAAC"}
|
|
@@ -3,72 +3,53 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.affineAdjustmentRsquaredExercise = void 0;
|
|
4
4
|
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
-
const randint_1 = require("../../../../math/utils/random/randint");
|
|
7
6
|
const round_1 = require("../../../../math/utils/round");
|
|
7
|
+
const generateAffineCloud_1 = require("../../../../math/utils/stats/generateAffineCloud");
|
|
8
|
+
const rSquared_1 = require("../../../../math/utils/stats/rSquared");
|
|
8
9
|
const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
|
|
9
10
|
const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
|
|
10
11
|
const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
|
|
11
12
|
const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
|
|
12
13
|
const dollarize_1 = require("../../../../utils/latex/dollarize");
|
|
13
14
|
const mdTable_1 = require("../../../../utils/markdown/mdTable");
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const intercept = (0, randint_1.randint)(100, 5000) / 100;
|
|
17
|
-
let data = [];
|
|
18
|
-
let generatedXs = new Set();
|
|
19
|
-
while (data.length < n) {
|
|
20
|
-
let x = (0, randint_1.randint)(1, 100);
|
|
21
|
-
while (generatedXs.has(x)) {
|
|
22
|
-
x = (0, randint_1.randint)(1, 100);
|
|
23
|
-
}
|
|
24
|
-
generatedXs.add(x);
|
|
25
|
-
let noise = Math.random() * 100;
|
|
26
|
-
let y = (0, round_1.round)(slope * x + intercept + noise, 2);
|
|
27
|
-
data.push({ x, y });
|
|
28
|
-
}
|
|
29
|
-
return data;
|
|
30
|
-
}
|
|
31
|
-
function calculateRSquared(xValues, yValues) {
|
|
32
|
-
const n = xValues.length;
|
|
33
|
-
const sumX = xValues.reduce((acc, x) => acc + x, 0);
|
|
34
|
-
const sumY = yValues.reduce((acc, y) => acc + y, 0);
|
|
35
|
-
const sumXY = xValues.reduce((acc, x, i) => acc + x * yValues[i], 0);
|
|
36
|
-
const sumX2 = xValues.reduce((acc, x) => acc + x * x, 0);
|
|
37
|
-
const sumY2 = yValues.reduce((acc, y) => acc + y * y, 0);
|
|
38
|
-
const numerator = n * sumXY - sumX * sumY;
|
|
39
|
-
const denominator = Math.sqrt((n * sumX2 - sumX * sumX) * (n * sumY2 - sumY * sumY));
|
|
40
|
-
const r = numerator / denominator;
|
|
41
|
-
const rSquared = r * r;
|
|
42
|
-
return (0, round_1.round)(rSquared, 2);
|
|
43
|
-
}
|
|
44
|
-
const getAffineAdjustmentRsquaredQuestion = () => {
|
|
45
|
-
const data = generateLinearData(6);
|
|
46
|
-
data.sort((a, b) => a.x - b.x);
|
|
47
|
-
const xValues = data.map((point) => (0, round_1.round)(point.x, 1));
|
|
48
|
-
const yValues = data.map((point) => (0, round_1.round)(point.y, 1));
|
|
49
|
-
const rSquared = calculateRSquared(xValues, yValues);
|
|
50
|
-
const answer = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), rSquared.toTree()).toTex();
|
|
15
|
+
const getInstruction = (identifiers) => {
|
|
16
|
+
const { xValues, yValues } = identifiers;
|
|
51
17
|
let dataTable = (0, mdTable_1.mdTable)([
|
|
52
18
|
["$x$", ...xValues.map((n) => (0, dollarize_1.dollarize)(n.frenchify()))],
|
|
53
19
|
["$y$", ...yValues.map((n) => (0, dollarize_1.dollarize)(n.frenchify()))],
|
|
54
20
|
]);
|
|
21
|
+
return `On considère la série statistique ci-dessous. Déterminez la valeur du coefficient de détermination. ${dataTable}
|
|
22
|
+
`;
|
|
23
|
+
};
|
|
24
|
+
const getAnswer = (identifiers) => {
|
|
25
|
+
const { xValues, yValues } = identifiers;
|
|
26
|
+
const r2 = (0, round_1.round)((0, rSquared_1.rSquared)(xValues, yValues), 2);
|
|
27
|
+
const answer = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), r2.toTree()).toTex();
|
|
28
|
+
return answer;
|
|
29
|
+
};
|
|
30
|
+
const getAffineAdjustmentRsquaredQuestion = () => {
|
|
31
|
+
const data = (0, generateAffineCloud_1.generateAffineCloud)(6);
|
|
32
|
+
data.sort((a, b) => a.x - b.x);
|
|
33
|
+
const xValues = data.map((point) => (0, round_1.round)(point.x, 1));
|
|
34
|
+
const yValues = data.map((point) => (0, round_1.round)(point.y, 1));
|
|
35
|
+
const identifiers = { xValues, yValues };
|
|
55
36
|
const question = {
|
|
56
|
-
answer:
|
|
57
|
-
instruction:
|
|
58
|
-
`,
|
|
37
|
+
answer: getAnswer(identifiers),
|
|
38
|
+
instruction: getInstruction(identifiers),
|
|
59
39
|
keys: ["R", "equal"],
|
|
60
40
|
answerFormat: "tex",
|
|
61
|
-
identifiers
|
|
41
|
+
identifiers,
|
|
62
42
|
style: { tableHasNoHeader: true },
|
|
63
43
|
};
|
|
64
44
|
return question;
|
|
65
45
|
};
|
|
66
|
-
const getPropositions = (n, { answer,
|
|
46
|
+
const getPropositions = (n, { answer, xValues, yValues }) => {
|
|
67
47
|
const propositions = [];
|
|
48
|
+
const r2 = (0, round_1.round)((0, rSquared_1.rSquared)(xValues, yValues), 2);
|
|
68
49
|
(0, exercise_1.addValidProp)(propositions, answer, "tex");
|
|
69
|
-
const wrongAnswer1 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("R"),
|
|
70
|
-
const wrongAnswer2 = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), (
|
|
71
|
-
const wrongAnswer3 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("R"), (
|
|
50
|
+
const wrongAnswer1 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("R"), r2.toTree()).toTex();
|
|
51
|
+
const wrongAnswer2 = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), (r2 + 0.01).toTree()).toTex();
|
|
52
|
+
const wrongAnswer3 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("R"), (r2 - 0.01).toTree()).toTex();
|
|
72
53
|
(0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer1);
|
|
73
54
|
(0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer2);
|
|
74
55
|
(0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer3);
|
|
@@ -78,8 +59,9 @@ const getPropositions = (n, { answer, rSquared }) => {
|
|
|
78
59
|
}
|
|
79
60
|
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
80
61
|
};
|
|
81
|
-
const isAnswerValid = (ans, {
|
|
82
|
-
const
|
|
62
|
+
const isAnswerValid = (ans, { xValues, yValues }) => {
|
|
63
|
+
const r2 = (0, round_1.round)((0, rSquared_1.rSquared)(xValues, yValues), 2);
|
|
64
|
+
const validanswer = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), r2.toTree());
|
|
83
65
|
const latexs = validanswer.toAllValidTexs({
|
|
84
66
|
allowRawRightChildAsSolution: true,
|
|
85
67
|
allowFractionToDecimal: true,
|
|
@@ -98,4 +80,6 @@ exports.affineAdjustmentRsquaredExercise = {
|
|
|
98
80
|
getPropositions,
|
|
99
81
|
isAnswerValid,
|
|
100
82
|
subject: "Mathématiques",
|
|
83
|
+
getAnswer,
|
|
84
|
+
getInstruction,
|
|
101
85
|
};
|
|
@@ -4,7 +4,7 @@ exports.productCell = void 0;
|
|
|
4
4
|
const exercise_1 = require("../../../exercises/exercise");
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
6
|
const randint_1 = require("../../../math/utils/random/randint");
|
|
7
|
-
const sum_1 = require("../../../math/utils/sum");
|
|
7
|
+
const sum_1 = require("../../../math/utils/stats/sum");
|
|
8
8
|
const addNode_1 = require("../../../tree/nodes/operators/addNode");
|
|
9
9
|
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
10
10
|
const variableNode_1 = require("../../../tree/nodes/variables/variableNode");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probaFromTableWithContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableWithContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"probaFromTableWithContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableWithContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AA4IF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAsBF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoBpE,CAAC"}
|
|
@@ -4,7 +4,7 @@ exports.interquartilesList = void 0;
|
|
|
4
4
|
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
6
|
const numberVEA_1 = require("../../../../exercises/vea/numberVEA");
|
|
7
|
-
const quartiles_1 = require("../../../../math/utils/quartiles");
|
|
7
|
+
const quartiles_1 = require("../../../../math/utils/stats/quartiles");
|
|
8
8
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
9
9
|
const approxOrEqual_1 = require("../../../../utils/latex/approxOrEqual");
|
|
10
10
|
const getPropositions = (n, { answer }) => {
|
|
@@ -4,7 +4,7 @@ exports.interquartilesTable = void 0;
|
|
|
4
4
|
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
6
|
const numberVEA_1 = require("../../../../exercises/vea/numberVEA");
|
|
7
|
-
const quartiles_1 = require("../../../../math/utils/quartiles");
|
|
7
|
+
const quartiles_1 = require("../../../../math/utils/stats/quartiles");
|
|
8
8
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
9
9
|
const approxOrEqual_1 = require("../../../../utils/latex/approxOrEqual");
|
|
10
10
|
const mdTable_1 = require("../../../../utils/markdown/mdTable");
|
|
@@ -7,8 +7,8 @@ const sqrtVEA_1 = require("../../../../exercises/vea/sqrtVEA");
|
|
|
7
7
|
const randfloat_1 = require("../../../../math/utils/random/randfloat");
|
|
8
8
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
9
9
|
const round_1 = require("../../../../math/utils/round");
|
|
10
|
-
const standardDeviation_1 = require("../../../../math/utils/standardDeviation");
|
|
11
|
-
const variance_1 = require("../../../../math/utils/variance");
|
|
10
|
+
const standardDeviation_1 = require("../../../../math/utils/stats/standardDeviation");
|
|
11
|
+
const variance_1 = require("../../../../math/utils/stats/variance");
|
|
12
12
|
const average_1 = require("../../../../utils/average");
|
|
13
13
|
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
14
14
|
const approxOrEqual_1 = require("../../../../utils/latex/approxOrEqual");
|
|
@@ -7,8 +7,8 @@ const sqrtVEA_1 = require("../../../../exercises/vea/sqrtVEA");
|
|
|
7
7
|
const randfloat_1 = require("../../../../math/utils/random/randfloat");
|
|
8
8
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
9
9
|
const round_1 = require("../../../../math/utils/round");
|
|
10
|
-
const standardDeviation_1 = require("../../../../math/utils/standardDeviation");
|
|
11
|
-
const variance_1 = require("../../../../math/utils/variance");
|
|
10
|
+
const standardDeviation_1 = require("../../../../math/utils/stats/standardDeviation");
|
|
11
|
+
const variance_1 = require("../../../../math/utils/stats/variance");
|
|
12
12
|
const average_1 = require("../../../../utils/average");
|
|
13
13
|
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
14
14
|
const approxOrEqual_1 = require("../../../../utils/latex/approxOrEqual");
|
|
@@ -7,7 +7,7 @@ const rationalVEA_1 = require("../../../../exercises/vea/rationalVEA");
|
|
|
7
7
|
const randfloat_1 = require("../../../../math/utils/random/randfloat");
|
|
8
8
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
9
9
|
const round_1 = require("../../../../math/utils/round");
|
|
10
|
-
const variance_1 = require("../../../../math/utils/variance");
|
|
10
|
+
const variance_1 = require("../../../../math/utils/stats/variance");
|
|
11
11
|
const average_1 = require("../../../../utils/average");
|
|
12
12
|
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
13
13
|
const approxOrEqual_1 = require("../../../../utils/latex/approxOrEqual");
|
|
@@ -7,7 +7,7 @@ const rationalVEA_1 = require("../../../../exercises/vea/rationalVEA");
|
|
|
7
7
|
const randfloat_1 = require("../../../../math/utils/random/randfloat");
|
|
8
8
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
9
9
|
const round_1 = require("../../../../math/utils/round");
|
|
10
|
-
const variance_1 = require("../../../../math/utils/variance");
|
|
10
|
+
const variance_1 = require("../../../../math/utils/stats/variance");
|
|
11
11
|
const average_1 = require("../../../../utils/average");
|
|
12
12
|
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
13
13
|
const approxOrEqual_1 = require("../../../../utils/latex/approxOrEqual");
|
package/lib/index.d.ts
CHANGED
|
@@ -640,22 +640,12 @@ declare const mathExercises: (Exercise<{
|
|
|
640
640
|
b: number;
|
|
641
641
|
isAskingA: boolean;
|
|
642
642
|
}, {}> | Exercise<{
|
|
643
|
-
G1x: number;
|
|
644
|
-
G2x: number;
|
|
645
|
-
G2y: number;
|
|
646
|
-
G1y: number;
|
|
647
643
|
xValues: number[];
|
|
648
644
|
yValues: number[];
|
|
649
645
|
}, {}> | Exercise<{
|
|
650
|
-
rSquared: number;
|
|
651
646
|
xValues: number[];
|
|
652
647
|
yValues: number[];
|
|
653
648
|
}, {}> | Exercise<{
|
|
654
|
-
G1x: number;
|
|
655
|
-
G2x: number;
|
|
656
|
-
G2y: number;
|
|
657
|
-
G1y: number;
|
|
658
|
-
rSquared: number;
|
|
659
649
|
xValues: number[];
|
|
660
650
|
yValues: number[];
|
|
661
651
|
}, {}> | Exercise<{
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -8,8 +8,8 @@ const variableNode_1 = require("../../tree/nodes/variables/variableNode");
|
|
|
8
8
|
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
9
9
|
const addNode_1 = require("../../tree/nodes/operators/addNode");
|
|
10
10
|
const randint_1 = require("../utils/random/randint");
|
|
11
|
-
const covariance_1 = require("../utils/covariance");
|
|
12
|
-
const variance_1 = require("../utils/variance");
|
|
11
|
+
const covariance_1 = require("../utils/stats/covariance");
|
|
12
|
+
const variance_1 = require("../utils/stats/variance");
|
|
13
13
|
class CloudPointsConstructor {
|
|
14
14
|
static random(nbPoints) {
|
|
15
15
|
const names = [];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Binomial = void 0;
|
|
4
4
|
const combination_1 = require("../utils/combinatorics/combination");
|
|
5
|
-
const sum_1 = require("../utils/sum");
|
|
5
|
+
const sum_1 = require("../utils/stats/sum");
|
|
6
6
|
class Binomial {
|
|
7
7
|
constructor(n, p) {
|
|
8
8
|
this.n = n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round.d.ts","sourceRoot":"","sources":["../../../src/math/utils/round.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"round.d.ts","sourceRoot":"","sources":["../../../src/math/utils/round.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CACnB,CAAC,EAAE,MAAM,EACT,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,OAAO,GACrB,MAAM,CAqBR;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAG5D"}
|
package/lib/math/utils/round.js
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.roundSignificant = exports.round = void 0;
|
|
4
|
-
const epsilon_1 = require("../numbers/epsilon");
|
|
5
4
|
function round(x, precision, fillDecimals) {
|
|
6
|
-
|
|
7
|
-
Math.
|
|
5
|
+
if (!("" + x).includes("e")) {
|
|
6
|
+
return +(Math.round(Number(x + "e+" + precision)) + "e-" + precision);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
const arr = ("" + x).split("e");
|
|
10
|
+
let sig = "";
|
|
11
|
+
if (+arr[1] + precision > 0) {
|
|
12
|
+
sig = "+";
|
|
13
|
+
}
|
|
14
|
+
return +(Math.round(Number(+arr[0] + "e" + sig + (+arr[1] + precision))) +
|
|
15
|
+
"e-" +
|
|
16
|
+
precision);
|
|
17
|
+
}
|
|
18
|
+
// return +(Math.round(Number(x + "e+" + precision)) + "e-" + precision);
|
|
19
|
+
// return (
|
|
20
|
+
// Math.round((x + Number.EPSILON) * Math.pow(10, precision)) /
|
|
21
|
+
// Math.pow(10, precision)
|
|
22
|
+
// );
|
|
8
23
|
}
|
|
9
24
|
exports.round = round;
|
|
10
25
|
function roundSignificant(x, precision) {
|
|
11
|
-
const rounded =
|
|
12
|
-
Math.pow(10, precision);
|
|
26
|
+
const rounded = round(x, precision);
|
|
13
27
|
return rounded.toFixed(precision).replace(".", ",");
|
|
14
28
|
}
|
|
15
29
|
exports.roundSignificant = roundSignificant;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../../../tree/nodes/algebraicNode";
|
|
2
|
+
export declare function covXYAsNode(xValues: number[], avgX: AlgebraicNode, yValues: number[], avgY: AlgebraicNode): AlgebraicNode;
|
|
3
|
+
export declare function covarianceXY(xValues: number[], avgX: number, yValues: number[], avgY: number): number;
|
|
4
|
+
//# sourceMappingURL=covariance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"covariance.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/stats/covariance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAO/D,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,EAAE,aAAa,GAClB,aAAa,CAef;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,EAAE,MAAM,GACX,MAAM,CASR"}
|