math-exercises 1.4.7 → 1.4.9
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/exercises.d.ts.map +1 -1
- package/lib/exercises/exercises.js +6 -0
- package/lib/exercises/probaStat/ballsBasicProbas.d.ts +4 -0
- package/lib/exercises/probaStat/ballsBasicProbas.d.ts.map +1 -0
- package/lib/exercises/probaStat/ballsBasicProbas.js +70 -0
- package/lib/exercises/probaStat/cardBasicProbas.d.ts +4 -0
- package/lib/exercises/probaStat/cardBasicProbas.d.ts.map +1 -0
- package/lib/exercises/probaStat/cardBasicProbas.js +103 -0
- package/lib/exercises/probaStat/diceBasicProbas.d.ts +4 -0
- package/lib/exercises/probaStat/diceBasicProbas.d.ts.map +1 -0
- package/lib/exercises/probaStat/diceBasicProbas.js +77 -0
- package/lib/exercises/utils/cardsData.d.ts +22 -0
- package/lib/exercises/utils/cardsData.d.ts.map +1 -0
- package/lib/exercises/utils/cardsData.js +26 -0
- package/lib/utils/enumToArray.d.ts +8 -0
- package/lib/utils/enumToArray.d.ts.map +1 -0
- package/lib/utils/enumToArray.js +16 -0
- package/lib/utils/probaFlip.d.ts +5 -0
- package/lib/utils/probaFlip.d.ts.map +1 -1
- package/lib/utils/probaFlip.js +5 -0
- package/lib/utils/probaLawFlip.d.ts +2 -0
- package/lib/utils/probaLawFlip.d.ts.map +1 -0
- package/lib/utils/probaLawFlip.js +19 -0
- package/lib/utils/randomEnumValue.d.ts +2 -0
- package/lib/utils/randomEnumValue.d.ts.map +1 -0
- package/lib/utils/randomEnumValue.js +9 -0
- package/package.json +1 -1
- package/lib/exercises/calculLitteral/equation/evaluateExpression.d.ts +0 -4
- package/lib/exercises/calculLitteral/equation/evaluateExpression.d.ts.map +0 -1
- package/lib/exercises/calculLitteral/equation/evaluateExpression.js +0 -61
- package/lib/exercises/calculLitteral/equation/firstDegreeGeneralEquation.d.ts +0 -4
- package/lib/exercises/calculLitteral/equation/firstDegreeGeneralEquation.d.ts.map +0 -1
- package/lib/exercises/calculLitteral/equation/firstDegreeGeneralEquation.js +0 -32
- package/lib/exercises/functions/affines/template.d.ts +0 -4
- package/lib/exercises/functions/affines/template.d.ts.map +0 -1
- package/lib/exercises/functions/affines/template.js +0 -51
- package/lib/exercises/geometry/cartesian/imageFunction.d.ts +0 -4
- package/lib/exercises/geometry/cartesian/imageFunction.d.ts.map +0 -1
- package/lib/exercises/geometry/cartesian/imageFunction.js +0 -65
- package/lib/exercises/geometry/cartesian/imageFunctionGeogebra.d.ts +0 -4
- package/lib/exercises/geometry/cartesian/imageFunctionGeogebra.d.ts.map +0 -1
- package/lib/exercises/geometry/cartesian/imageFunctionGeogebra.js +0 -89
- package/lib/exercises/geometry/cartesian/inverseImageFunction.d.ts +0 -4
- package/lib/exercises/geometry/cartesian/inverseImageFunction.d.ts.map +0 -1
- package/lib/exercises/geometry/cartesian/inverseImageFunction.js +0 -62
- package/lib/exercises/geometry/cartesian/inverseImageFunctionGeogebra.d.ts +0 -4
- package/lib/exercises/geometry/cartesian/inverseImageFunctionGeogebra.d.ts.map +0 -1
- package/lib/exercises/geometry/cartesian/inverseImageFunctionGeogebra.js +0 -154
- package/lib/exercises/geometry/cartesian/leadingCoefficient.d.ts +0 -4
- package/lib/exercises/geometry/cartesian/leadingCoefficient.d.ts.map +0 -1
- package/lib/exercises/geometry/cartesian/leadingCoefficient.js +0 -93
- package/lib/exercises/geometry/cartesian/leadingCoefficientCalculV1.d.ts +0 -4
- package/lib/exercises/geometry/cartesian/leadingCoefficientCalculV1.d.ts.map +0 -1
- package/lib/exercises/geometry/cartesian/leadingCoefficientCalculV1.js +0 -59
- package/lib/exercises/geometry/cartesian/leadingCoefficientCalculV2.d.ts +0 -4
- package/lib/exercises/geometry/cartesian/leadingCoefficientCalculV2.d.ts.map +0 -1
- package/lib/exercises/geometry/cartesian/leadingCoefficientCalculV2.js +0 -58
- package/lib/exercises/geometry/cartesian/signFunction.d.ts +0 -4
- package/lib/exercises/geometry/cartesian/signFunction.d.ts.map +0 -1
- package/lib/exercises/geometry/cartesian/signFunction.js +0 -84
- package/lib/exercises/limits/polynomeLimit.d.ts +0 -4
- package/lib/exercises/limits/polynomeLimit.d.ts.map +0 -1
- package/lib/exercises/limits/polynomeLimit.js +0 -134
- package/lib/exercises/proba/conditionalProbability.d.ts +0 -4
- package/lib/exercises/proba/conditionalProbability.d.ts.map +0 -1
- package/lib/exercises/proba/conditionalProbability.js +0 -99
- package/lib/exercises/proba/marginalAndConditionalFrequency.d.ts +0 -4
- package/lib/exercises/proba/marginalAndConditionalFrequency.d.ts.map +0 -1
- package/lib/exercises/proba/marginalAndConditionalFrequency.js +0 -106
- package/lib/exercises/proba/probabilityTree.d.ts +0 -4
- package/lib/exercises/proba/probabilityTree.d.ts.map +0 -1
- package/lib/exercises/proba/probabilityTree.js +0 -132
- package/lib/exercises/probaStat/frequencyTable.d.ts +0 -4
- package/lib/exercises/probaStat/frequencyTable.d.ts.map +0 -1
- package/lib/exercises/probaStat/frequencyTable.js +0 -76
- package/lib/exercises/sequences/arithmetic/arithmeticSum.d.ts +0 -1
- package/lib/exercises/sequences/arithmetic/arithmeticSum.d.ts.map +0 -1
- package/lib/exercises/sequences/arithmetic/arithmeticSum.js +0 -1
- package/lib/exercises/sets/intervalsUnion.d.ts +0 -4
- package/lib/exercises/sets/intervalsUnion.d.ts.map +0 -1
- package/lib/exercises/sets/intervalsUnion.js +0 -55
- package/lib/exercises/utils/sum.test.d.ts +0 -2
- package/lib/exercises/utils/sum.test.d.ts.map +0 -1
- package/lib/exercises/utils/sum.test.js +0 -22
- package/lib/math/numbers/reals/squareRoot.d.ts +0 -19
- package/lib/math/numbers/reals/squareRoot.d.ts.map +0 -1
- package/lib/math/numbers/reals/squareRoot.js +0 -63
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signFunction.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/cartesian/signFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAU3E,eAAO,MAAM,YAAY,EAAE,QAU1B,CAAC;AAEF,wBAAgB,eAAe,IAAI,QAAQ,CAuE1C"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSignFunction = exports.signFunction = void 0;
|
|
4
|
-
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
5
|
-
const polynomial_1 = require("../../../math/polynomials/polynomial");
|
|
6
|
-
const randint_1 = require("../../../math/utils/random/randint");
|
|
7
|
-
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
8
|
-
const simplify_1 = require("../../../tree/parsers/simplify");
|
|
9
|
-
const coinFlip_1 = require("../../../utils/coinFlip");
|
|
10
|
-
const shuffle_1 = require("../../../utils/shuffle");
|
|
11
|
-
const uuid_1 = require("uuid");
|
|
12
|
-
exports.signFunction = {
|
|
13
|
-
id: 'signFunction',
|
|
14
|
-
connector: '=',
|
|
15
|
-
instruction: '',
|
|
16
|
-
label: "Signe d'une fonction affine",
|
|
17
|
-
levels: ['4', '3', '2'],
|
|
18
|
-
section: 'Fonctions affines',
|
|
19
|
-
isSingleStep: true,
|
|
20
|
-
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getSignFunction, nb),
|
|
21
|
-
keys: ['S', 'equal', 'lbracket', 'rbracket', 'semicolon', 'infty'],
|
|
22
|
-
};
|
|
23
|
-
function getSignFunction() {
|
|
24
|
-
const a = (0, randint_1.randint)(-9, 10, [0]);
|
|
25
|
-
const b = (0, randint_1.randint)(-9, 10);
|
|
26
|
-
const affine = new polynomial_1.Polynomial([b, a]);
|
|
27
|
-
let instruction = `Soit $f$ la fonction définie par : $f(x) = ${affine.toTex()}$. Sur quel intervalle $f$ est-elle `;
|
|
28
|
-
let answer = '';
|
|
29
|
-
switch ((0, coinFlip_1.coinFlip)()) {
|
|
30
|
-
case true:
|
|
31
|
-
instruction += 'positive ?';
|
|
32
|
-
answer =
|
|
33
|
-
a > 0
|
|
34
|
-
? `\\left[${(0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(-b / a)).toTex()};+\\infty\\right[`
|
|
35
|
-
: `\\left]-\\infty;${(0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(-b / a)).toTex()}\\right]`;
|
|
36
|
-
break;
|
|
37
|
-
case false:
|
|
38
|
-
instruction += 'négative ?';
|
|
39
|
-
answer =
|
|
40
|
-
a > 0
|
|
41
|
-
? `\\left]-\\infty;${(0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(-b / a)).toTex()}\\right]`
|
|
42
|
-
: `\\left[${(0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(-b / a)).toTex()};+\\infty\\left[`;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
const getPropositions = (n) => {
|
|
46
|
-
const res = [];
|
|
47
|
-
res.push({
|
|
48
|
-
id: (0, uuid_1.v4)() + '',
|
|
49
|
-
statement: answer,
|
|
50
|
-
isRightAnswer: true,
|
|
51
|
-
format: 'tex',
|
|
52
|
-
});
|
|
53
|
-
for (let i = 0; i < n - 1; i++) {
|
|
54
|
-
let isDuplicate;
|
|
55
|
-
let proposition;
|
|
56
|
-
do {
|
|
57
|
-
const a = (0, randint_1.randint)(-9, 10, [0]);
|
|
58
|
-
const b = (0, randint_1.randint)(-9, 10);
|
|
59
|
-
const wrongAnswer = (0, coinFlip_1.coinFlip)()
|
|
60
|
-
? `\\left[${(0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(-b / a)).toTex()};+\\infty\\right[`
|
|
61
|
-
: `\\left]-\\infty;${(0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(-b / a)).toTex()}\\right]`;
|
|
62
|
-
proposition = {
|
|
63
|
-
id: (0, uuid_1.v4)() + '',
|
|
64
|
-
statement: wrongAnswer,
|
|
65
|
-
isRightAnswer: false,
|
|
66
|
-
format: 'tex',
|
|
67
|
-
};
|
|
68
|
-
isDuplicate = res.some((p) => p.statement === proposition.statement);
|
|
69
|
-
} while (isDuplicate);
|
|
70
|
-
res.push(proposition);
|
|
71
|
-
}
|
|
72
|
-
return (0, shuffle_1.shuffle)(res);
|
|
73
|
-
};
|
|
74
|
-
const question = {
|
|
75
|
-
instruction,
|
|
76
|
-
startStatement: 'S',
|
|
77
|
-
answer,
|
|
78
|
-
keys: ['S', 'equal', 'lbracket', 'rbracket', 'semicolon', 'infty'],
|
|
79
|
-
getPropositions,
|
|
80
|
-
answerFormat: 'tex',
|
|
81
|
-
};
|
|
82
|
-
return question;
|
|
83
|
-
}
|
|
84
|
-
exports.getSignFunction = getSignFunction;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polynomeLimit.d.ts","sourceRoot":"","sources":["../../../src/exercises/limits/polynomeLimit.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIlE,eAAO,MAAM,aAAa,EAAE,YAY3B,CAAC;AAEF,wBAAgB,uBAAuB,IAAI,QAAQ,CAgIlD"}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getApplyPercentQuestion = exports.polynomeLimit = void 0;
|
|
4
|
-
const polynomial_1 = require("../../math/polynomials/polynomial");
|
|
5
|
-
const randint_1 = require("../../math/utils/random/randint");
|
|
6
|
-
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
7
|
-
const fractionNode_1 = require("../../tree/nodes/operators/fractionNode");
|
|
8
|
-
const simplify_1 = require("../../tree/parsers/simplify");
|
|
9
|
-
const coinFlip_1 = require("../../utils/coinFlip");
|
|
10
|
-
const shuffle_1 = require("../../utils/shuffle");
|
|
11
|
-
const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
|
|
12
|
-
const uuid_1 = require("uuid");
|
|
13
|
-
exports.polynomeLimit = {
|
|
14
|
-
id: 'polynomeLimit',
|
|
15
|
-
connector: '=',
|
|
16
|
-
instruction: '',
|
|
17
|
-
label: "Calculer la limite d'une fonction polynomiale",
|
|
18
|
-
levels: ['TermSpé'],
|
|
19
|
-
sections: ['Limites'],
|
|
20
|
-
isSingleStep: true,
|
|
21
|
-
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getApplyPercentQuestion, nb),
|
|
22
|
-
keys: ['infty'],
|
|
23
|
-
qcmTimer: 60,
|
|
24
|
-
freeTimer: 60,
|
|
25
|
-
};
|
|
26
|
-
function getApplyPercentQuestion() {
|
|
27
|
-
const polynome1 = polynomial_1.PolynomialConstructor.randomWithOrder((0, randint_1.randint)(2, 6));
|
|
28
|
-
const polynome2 = polynomial_1.PolynomialConstructor.randomWithOrder((0, randint_1.randint)(2, 6));
|
|
29
|
-
// a_1x^n + b_2x^(n-1) + ...
|
|
30
|
-
const a1 = polynome1.coefficients[polynome1.coefficients.length - 1];
|
|
31
|
-
const a2 = polynome2.coefficients[polynome2.coefficients.length - 1];
|
|
32
|
-
const rand = (0, coinFlip_1.coinFlip)(); // polynome ou fraction
|
|
33
|
-
const randLimite = (0, coinFlip_1.coinFlip)() ? 1 : -1; // + infini ou - infini
|
|
34
|
-
let instruction = '';
|
|
35
|
-
let answer = '';
|
|
36
|
-
if (rand) {
|
|
37
|
-
instruction = `Déterminer la limite en $${randLimite > 0 ? `+` : `-`} \\infty$ de la fonction $f$ définie par : $f(x)$ = $${polynome1.toTex()}$.`;
|
|
38
|
-
answer = a1 * randLimite ** polynome1.degree > 0 ? `+\\infty` : `-\\infty`;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
instruction = `Déterminer la limite en $${randLimite > 0 ? `+` : `-`} \\infty$ de la fonction $f$ définie par : $f(x)$ = $${new fractionNode_1.FractionNode(polynome1.toTree(), polynome2.toTree()).toTex()}$.`;
|
|
42
|
-
if (polynome1.degree > polynome2.degree)
|
|
43
|
-
answer = a1 * randLimite > 0 ? `+\\infty` : `-\\infty`;
|
|
44
|
-
else if (polynome2.degree > polynome1.degree)
|
|
45
|
-
answer = '0';
|
|
46
|
-
else
|
|
47
|
-
answer = (0, simplify_1.simplifyNode)(new fractionNode_1.FractionNode(new numberNode_1.NumberNode(a1), new numberNode_1.NumberNode(a2))).toTex();
|
|
48
|
-
}
|
|
49
|
-
const getPropositions = (n) => {
|
|
50
|
-
const res = [];
|
|
51
|
-
let wrongAnswer = '';
|
|
52
|
-
let k = n - 1;
|
|
53
|
-
res.push({
|
|
54
|
-
id: (0, uuid_1.v4)() + '',
|
|
55
|
-
statement: answer,
|
|
56
|
-
isRightAnswer: true,
|
|
57
|
-
format: 'tex',
|
|
58
|
-
});
|
|
59
|
-
wrongAnswer = `+\\infty`;
|
|
60
|
-
if (k > 0 && answer !== wrongAnswer) {
|
|
61
|
-
res.push({
|
|
62
|
-
id: (0, uuid_1.v4)() + '',
|
|
63
|
-
statement: wrongAnswer,
|
|
64
|
-
isRightAnswer: false,
|
|
65
|
-
format: 'tex',
|
|
66
|
-
});
|
|
67
|
-
k--;
|
|
68
|
-
}
|
|
69
|
-
wrongAnswer = `-\\infty`;
|
|
70
|
-
if (k > 0 && answer !== wrongAnswer) {
|
|
71
|
-
res.push({
|
|
72
|
-
id: (0, uuid_1.v4)() + '',
|
|
73
|
-
statement: wrongAnswer,
|
|
74
|
-
isRightAnswer: false,
|
|
75
|
-
format: 'tex',
|
|
76
|
-
});
|
|
77
|
-
k--;
|
|
78
|
-
}
|
|
79
|
-
wrongAnswer = `0`;
|
|
80
|
-
if (k > 0 && answer !== wrongAnswer) {
|
|
81
|
-
res.push({
|
|
82
|
-
id: (0, uuid_1.v4)() + '',
|
|
83
|
-
statement: wrongAnswer,
|
|
84
|
-
isRightAnswer: false,
|
|
85
|
-
format: 'tex',
|
|
86
|
-
});
|
|
87
|
-
k--;
|
|
88
|
-
}
|
|
89
|
-
wrongAnswer = (0, simplify_1.simplifyNode)(new fractionNode_1.FractionNode(new numberNode_1.NumberNode(a1), new numberNode_1.NumberNode(a2))).toTex();
|
|
90
|
-
if (!rand && k > 0 && answer !== wrongAnswer) {
|
|
91
|
-
res.push({
|
|
92
|
-
id: (0, uuid_1.v4)() + '',
|
|
93
|
-
statement: wrongAnswer,
|
|
94
|
-
isRightAnswer: false,
|
|
95
|
-
format: 'tex',
|
|
96
|
-
});
|
|
97
|
-
k--;
|
|
98
|
-
}
|
|
99
|
-
wrongAnswer = `${a1}`;
|
|
100
|
-
if (k > 0 && answer !== wrongAnswer) {
|
|
101
|
-
res.push({
|
|
102
|
-
id: (0, uuid_1.v4)() + '',
|
|
103
|
-
statement: wrongAnswer,
|
|
104
|
-
isRightAnswer: false,
|
|
105
|
-
format: 'tex',
|
|
106
|
-
});
|
|
107
|
-
k--;
|
|
108
|
-
}
|
|
109
|
-
for (let i = 0; i < k; i++) {
|
|
110
|
-
let isDuplicate;
|
|
111
|
-
let proposition;
|
|
112
|
-
do {
|
|
113
|
-
proposition = {
|
|
114
|
-
id: (0, uuid_1.v4)() + '',
|
|
115
|
-
statement: (0, randint_1.randint)(-9, 10) + '',
|
|
116
|
-
isRightAnswer: false,
|
|
117
|
-
format: 'tex',
|
|
118
|
-
};
|
|
119
|
-
isDuplicate = res.some((p) => p.statement === proposition.statement);
|
|
120
|
-
} while (isDuplicate);
|
|
121
|
-
res.push(proposition);
|
|
122
|
-
}
|
|
123
|
-
return (0, shuffle_1.shuffle)(res);
|
|
124
|
-
};
|
|
125
|
-
const question = {
|
|
126
|
-
instruction,
|
|
127
|
-
answer,
|
|
128
|
-
keys: ['infty'],
|
|
129
|
-
getPropositions,
|
|
130
|
-
answerFormat: 'tex',
|
|
131
|
-
};
|
|
132
|
-
return question;
|
|
133
|
-
}
|
|
134
|
-
exports.getApplyPercentQuestion = getApplyPercentQuestion;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditionalProbability.d.ts","sourceRoot":"","sources":["../../../src/exercises/proba/conditionalProbability.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAM9D,eAAO,MAAM,sBAAsB,EAAE,QAUpC,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,QAAQ,CA4GpD"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getConditionalProbability = exports.conditionalProbability = void 0;
|
|
4
|
-
const randint_1 = require("../../math/utils/random/randint");
|
|
5
|
-
const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
|
|
6
|
-
const round_1 = require("../../math/utils/round");
|
|
7
|
-
const shuffle_1 = require("../../utils/shuffle");
|
|
8
|
-
const uuid_1 = require("uuid");
|
|
9
|
-
exports.conditionalProbability = {
|
|
10
|
-
id: 'conditionalProbability',
|
|
11
|
-
connector: '=',
|
|
12
|
-
instruction: '',
|
|
13
|
-
label: 'Calcul de probabilité conditionnelle avec la formule de Bayes',
|
|
14
|
-
levels: ['1', '0'],
|
|
15
|
-
isSingleStep: false,
|
|
16
|
-
section: 'Probabilités',
|
|
17
|
-
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getConditionalProbability, nb),
|
|
18
|
-
keys: ['p', 'cap', 'underscore'],
|
|
19
|
-
};
|
|
20
|
-
function getConditionalProbability() {
|
|
21
|
-
const pA = (0, randint_1.randint)(2, 100);
|
|
22
|
-
const pB = (0, randint_1.randint)(2, 100);
|
|
23
|
-
const pAB = (0, randint_1.randint)(1, Math.min(pA, pB));
|
|
24
|
-
const pA_B = (0, round_1.round)(pAB / pB, 2);
|
|
25
|
-
const pB_A = (0, round_1.round)(pAB / pA, 2);
|
|
26
|
-
const flip = (0, randint_1.randint)(1, 7);
|
|
27
|
-
let instruction = `On considère deux événements A et B tels que `;
|
|
28
|
-
let startStatement = '';
|
|
29
|
-
let answer = '';
|
|
30
|
-
switch (flip) {
|
|
31
|
-
case 1: {
|
|
32
|
-
instruction += `$P(A) = ${(pA / 100 + '').replace('.', ',')}\\ $ et $\\ P(A \\cap B) = ${(pAB / 100 + '').replace('.', ',')}$.$\\\\$Déterminer $P_A(B)$.`;
|
|
33
|
-
startStatement = `P_A(B)`;
|
|
34
|
-
answer = `${pB_A}`;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
case 2: {
|
|
38
|
-
instruction += `$P(B) = ${(pB / 100 + '').replace('.', ',')}\\ $ et $\\ P(B \\cap A) = ${(pAB / 100 + '').replace('.', ',')}$.$\\\\$Déterminer $P_B(A)$.`;
|
|
39
|
-
startStatement = `P_B(A)`;
|
|
40
|
-
answer = `${pA_B}`;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
case 3: {
|
|
44
|
-
instruction += `$P(A) = ${(pA / 100 + '').replace('.', ',')}\\ $ et $\\ P_A(B) = ${(pB_A + '').replace('.', ',')}$.$\\\\$Déterminer $P(A \\cap B)$.`;
|
|
45
|
-
startStatement = `P(A \\cap B)`;
|
|
46
|
-
answer = `${pAB / 100}`;
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
case 4: {
|
|
50
|
-
instruction += `$P(B) = ${(pB / 100 + '').replace('.', ',')}\\ $ et $\\ P_B(A) = ${(pA_B + '').replace('.', ',')}$.$\\\\$Déterminer $P(A \\cap B)$.`;
|
|
51
|
-
startStatement = `P(A \\cap B)`;
|
|
52
|
-
answer = `${pAB / 100}`;
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
case 5: {
|
|
56
|
-
instruction += `$P(A \\cap B) = ${(pAB / 100 + '').replace('.', ',')}\\ $ et $\\ P_B(A) = ${(pA_B + '').replace('.', ',')}$.$\\\\$Déterminer $P(B)$.`;
|
|
57
|
-
startStatement = `P(B)`;
|
|
58
|
-
answer = `${pB / 100}`;
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
case 6: {
|
|
62
|
-
instruction += `$P(A \\cap B) = ${(pAB / 100 + '').replace('.', ',')}\\ $ et $\\ P_A(B) = ${(pB_A + '').replace('.', ',')}$.$\\\\$Déterminer $P(A)$.`;
|
|
63
|
-
startStatement = `P(A)`;
|
|
64
|
-
answer = `${pA / 100}`;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const getPropositions = (n) => {
|
|
69
|
-
const res = [];
|
|
70
|
-
res.push({
|
|
71
|
-
id: (0, uuid_1.v4)() + '',
|
|
72
|
-
statement: answer,
|
|
73
|
-
isRightAnswer: true,
|
|
74
|
-
});
|
|
75
|
-
for (let i = 0; i < n - 1; i++) {
|
|
76
|
-
let isDuplicate;
|
|
77
|
-
let proposition;
|
|
78
|
-
do {
|
|
79
|
-
proposition = {
|
|
80
|
-
id: (0, uuid_1.v4)() + '',
|
|
81
|
-
statement: Math.floor(Math.random() * 100) / 100 + '',
|
|
82
|
-
isRightAnswer: false,
|
|
83
|
-
};
|
|
84
|
-
isDuplicate = res.some((p) => p.statement === proposition.statement);
|
|
85
|
-
} while (isDuplicate);
|
|
86
|
-
res.push(proposition);
|
|
87
|
-
}
|
|
88
|
-
return (0, shuffle_1.shuffle)(res);
|
|
89
|
-
};
|
|
90
|
-
const question = {
|
|
91
|
-
instruction,
|
|
92
|
-
startStatement,
|
|
93
|
-
answer,
|
|
94
|
-
keys: ['p', 'cap', 'underscore'],
|
|
95
|
-
getPropositions,
|
|
96
|
-
};
|
|
97
|
-
return question;
|
|
98
|
-
}
|
|
99
|
-
exports.getConditionalProbability = getConditionalProbability;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"marginalAndConditionalFrequency.d.ts","sourceRoot":"","sources":["../../../src/exercises/proba/marginalAndConditionalFrequency.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI9D,eAAO,MAAM,+BAA+B,EAAE,QAU7C,CAAC;AAEF,wBAAgB,kCAAkC,IAAI,QAAQ,CAiG7D"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMarginalAndConditionalFrequency = exports.marginalAndConditionalFrequency = void 0;
|
|
4
|
-
const randint_1 = require("../../math/utils/random/randint");
|
|
5
|
-
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
6
|
-
const simplify_1 = require("../../tree/parsers/simplify");
|
|
7
|
-
const shuffle_1 = require("../../utils/shuffle");
|
|
8
|
-
const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
|
|
9
|
-
const uuid_1 = require("uuid");
|
|
10
|
-
exports.marginalAndConditionalFrequency = {
|
|
11
|
-
id: 'marginalAndConditionalFrequency',
|
|
12
|
-
connector: '=',
|
|
13
|
-
instruction: '',
|
|
14
|
-
label: 'Calculs de fréquences marginales et conditionnelles',
|
|
15
|
-
levels: ['1', '0'],
|
|
16
|
-
isSingleStep: false,
|
|
17
|
-
section: 'Probabilités',
|
|
18
|
-
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getMarginalAndConditionalFrequency, nb),
|
|
19
|
-
keys: ['f', 'cap', 'underscore'],
|
|
20
|
-
};
|
|
21
|
-
function getMarginalAndConditionalFrequency() {
|
|
22
|
-
const [x1, x2, x3, x4] = [1, 2, 3, 4].map((el) => (0, randint_1.randint)(1, 100));
|
|
23
|
-
const x = x1 + x2 + x3 + x4;
|
|
24
|
-
const rand = (0, randint_1.randint)(0, 12);
|
|
25
|
-
const freqString = [
|
|
26
|
-
'marginale de A',
|
|
27
|
-
'marginale de B',
|
|
28
|
-
'marginale de C',
|
|
29
|
-
'marginale de D',
|
|
30
|
-
'conditionnelle de A parmi C',
|
|
31
|
-
'conditionnelle de A parmi D',
|
|
32
|
-
'conditionnelle de B parmi C',
|
|
33
|
-
'conditionnelle de B parmi D',
|
|
34
|
-
'conditionnelle de C parmi A',
|
|
35
|
-
'conditionnelle de C parmi B',
|
|
36
|
-
'conditionnelle de D parmi A',
|
|
37
|
-
'conditionnelle de D parmi B',
|
|
38
|
-
];
|
|
39
|
-
const frequences = [
|
|
40
|
-
'f(A)',
|
|
41
|
-
'f(B)',
|
|
42
|
-
'f(C)',
|
|
43
|
-
'f(D)',
|
|
44
|
-
'f_C(A)',
|
|
45
|
-
'f_D(A)',
|
|
46
|
-
'f_C(B)',
|
|
47
|
-
'f_D(B)',
|
|
48
|
-
'f_A(C)',
|
|
49
|
-
'f_B(C)',
|
|
50
|
-
'f_A(D)',
|
|
51
|
-
'f_B(D)',
|
|
52
|
-
];
|
|
53
|
-
const Calculs = [
|
|
54
|
-
(x1 + x3) / x,
|
|
55
|
-
(x2 + x4) / x,
|
|
56
|
-
(x1 + x2) / x,
|
|
57
|
-
(x3 + x4) / x,
|
|
58
|
-
x1 / (x1 + x2),
|
|
59
|
-
x3 / (x3 + x4),
|
|
60
|
-
x2 / (x1 + x2),
|
|
61
|
-
x4 / (x3 + x4),
|
|
62
|
-
x1 / (x1 + x3),
|
|
63
|
-
x3 / (x1 + x3),
|
|
64
|
-
x2 / (x2 + x4),
|
|
65
|
-
x4 / (x2 + x4),
|
|
66
|
-
];
|
|
67
|
-
const calculsNodes = Calculs.map((el) => (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(el)));
|
|
68
|
-
const getPropositions = (n) => {
|
|
69
|
-
const res = [];
|
|
70
|
-
res.push({
|
|
71
|
-
id: (0, uuid_1.v4)() + '',
|
|
72
|
-
statement: calculsNodes[rand].toTex(),
|
|
73
|
-
isRightAnswer: true,
|
|
74
|
-
});
|
|
75
|
-
for (let i = 0; i < n - 1; i++) {
|
|
76
|
-
let isDuplicate;
|
|
77
|
-
let proposition;
|
|
78
|
-
do {
|
|
79
|
-
proposition = {
|
|
80
|
-
id: (0, uuid_1.v4)() + '',
|
|
81
|
-
statement: calculsNodes[(0, randint_1.randint)(0, 12, [rand])].toTex(),
|
|
82
|
-
isRightAnswer: false,
|
|
83
|
-
};
|
|
84
|
-
isDuplicate = res.some((p) => p.statement === proposition.statement);
|
|
85
|
-
} while (isDuplicate);
|
|
86
|
-
res.push(proposition);
|
|
87
|
-
}
|
|
88
|
-
return (0, shuffle_1.shuffle)(res);
|
|
89
|
-
};
|
|
90
|
-
const question = {
|
|
91
|
-
instruction: `On considère le tableau d'effectifs suivant :
|
|
92
|
-
|
|
93
|
-
| |A|B|
|
|
94
|
-
|-|-|-|
|
|
95
|
-
|C|${x1}|${x2}|
|
|
96
|
-
|D|${x3}|${x4}|
|
|
97
|
-
|
|
98
|
-
Calculer la fréquence ${freqString[rand]}.`,
|
|
99
|
-
startStatement: `${frequences[rand]}`,
|
|
100
|
-
answer: calculsNodes[rand].toTex(),
|
|
101
|
-
keys: ['f', 'cap', 'underscore'],
|
|
102
|
-
getPropositions,
|
|
103
|
-
};
|
|
104
|
-
return question;
|
|
105
|
-
}
|
|
106
|
-
exports.getMarginalAndConditionalFrequency = getMarginalAndConditionalFrequency;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"probabilityTree.d.ts","sourceRoot":"","sources":["../../../src/exercises/proba/probabilityTree.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI9D,eAAO,MAAM,eAAe,EAAE,QAS7B,CAAC;AAOF,wBAAgB,kBAAkB,IAAI,QAAQ,CAwH7C"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProbabilityTree = exports.probabilityTree = void 0;
|
|
4
|
-
const randint_1 = require("../../math/utils/random/randint");
|
|
5
|
-
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
6
|
-
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
7
|
-
const simplify_1 = require("../../tree/parsers/simplify");
|
|
8
|
-
const shuffle_1 = require("../../utils/shuffle");
|
|
9
|
-
const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
|
|
10
|
-
const uuid_1 = require("uuid");
|
|
11
|
-
exports.probabilityTree = {
|
|
12
|
-
id: 'probabilityTree',
|
|
13
|
-
connector: '=',
|
|
14
|
-
instruction: '',
|
|
15
|
-
label: "Calculs de probabilités à l'aide d'un arbre pondéré",
|
|
16
|
-
levels: ['1', '0'],
|
|
17
|
-
isSingleStep: false,
|
|
18
|
-
section: 'Probabilités',
|
|
19
|
-
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getProbabilityTree, nb),
|
|
20
|
-
};
|
|
21
|
-
function pgcd(a, b) {
|
|
22
|
-
while (b)
|
|
23
|
-
[a, b] = [b, a % b];
|
|
24
|
-
return a;
|
|
25
|
-
}
|
|
26
|
-
function getProbabilityTree() {
|
|
27
|
-
const A = (0, randint_1.randint)(2, 9);
|
|
28
|
-
const B = (0, randint_1.randint)(2, 10 - A);
|
|
29
|
-
const AC = (0, randint_1.randint)(2, 9);
|
|
30
|
-
const AD = (0, randint_1.randint)(2, 10 - AC);
|
|
31
|
-
const BC = (0, randint_1.randint)(2, 9);
|
|
32
|
-
const BD = (0, randint_1.randint)(2, 10 - BC);
|
|
33
|
-
const pA = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(A / (A + B)));
|
|
34
|
-
const pB = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(B / (A + B)));
|
|
35
|
-
const pA_C = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(AC / (AC + AD)));
|
|
36
|
-
const pA_D = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(AD / (AC + AD)));
|
|
37
|
-
const pB_C = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(BC / (BC + BD)));
|
|
38
|
-
const pB_D = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(BD / (BC + BD)));
|
|
39
|
-
let instruction = `En utilisant l'arbre de probabilité suivant, `;
|
|
40
|
-
let startStatement = '';
|
|
41
|
-
let answer;
|
|
42
|
-
const rand = (0, randint_1.randint)(1, 5);
|
|
43
|
-
switch (rand) {
|
|
44
|
-
case 1: {
|
|
45
|
-
instruction += `$\\\\$ Calculer $P(A \\cap C)$`;
|
|
46
|
-
startStatement = `P(A \\cap C)`;
|
|
47
|
-
answer = (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(pA, pA_C));
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
case 2: {
|
|
51
|
-
instruction += `$\\\\$ Calculer $P(A \\cap D)$`;
|
|
52
|
-
startStatement = `P(A \\cap D)`;
|
|
53
|
-
answer = (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(pA, pA_D));
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
case 3: {
|
|
57
|
-
instruction += `$\\\\$ Calculer $P(B \\cap C)$`;
|
|
58
|
-
startStatement = `P(B \\cap C)`;
|
|
59
|
-
answer = (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(pB, pB_C));
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
case 4: {
|
|
63
|
-
instruction += `$\\\\$ Calculer $P(B \\cap D)$`;
|
|
64
|
-
startStatement = `P(B \\cap D)`;
|
|
65
|
-
answer = (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(pB, pB_D));
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
default:
|
|
69
|
-
answer = (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(pB, pB_D)); // juste pour éviter l'erreur
|
|
70
|
-
}
|
|
71
|
-
let commands = [
|
|
72
|
-
'A = Point({2,2})',
|
|
73
|
-
'B = Point({2,-2})',
|
|
74
|
-
'AC = Point({5,3})',
|
|
75
|
-
'AD = Point({5,1})',
|
|
76
|
-
'BC = Point({5,-1})',
|
|
77
|
-
'BD = Point({5,-3})',
|
|
78
|
-
'Segment(Point({0,0}),A)',
|
|
79
|
-
'Segment(A,AC)',
|
|
80
|
-
'Segment(A,AD)',
|
|
81
|
-
'Segment(Point({0,0}),B)',
|
|
82
|
-
'Segment(B,BC)',
|
|
83
|
-
'Segment(B,BD)',
|
|
84
|
-
'ShowAxes(false)',
|
|
85
|
-
'ShowGrid(false)',
|
|
86
|
-
`Text("\\scriptsize${A / pgcd(A, A + B)}/${(A + B) / pgcd(A, A + B)}", (0.3, 2.1), true, true)`,
|
|
87
|
-
`Text("\\scriptsize${AC / pgcd(AC, AC + AD)}/${(AC + AD) / pgcd(AC, AC + AD)}", (2.8, 3.5), true, true)`,
|
|
88
|
-
`Text("\\scriptsize${AD / pgcd(AD, AC + AD)}/${(AC + AD) / pgcd(AD, AC + AD)}", (2.8, 1.4), true, true)`,
|
|
89
|
-
`Text("\\scriptsize${B / pgcd(B, A + B)}/${(A + B) / pgcd(B, A + B)}", (0.3, -1.2), true, true)`,
|
|
90
|
-
`Text("\\scriptsize${BC / pgcd(BC, BC + BD)}/${(BC + BD) / pgcd(BC, BC + BD)}", (2.8, -0.6), true, true)`,
|
|
91
|
-
`Text("\\scriptsize${BD / pgcd(BD, BC + BD)}/${(BC + BD) / pgcd(BD, BC + BD)}", (2.8, -2.5), true, true)`,
|
|
92
|
-
'Text("A", (1.85 , 2.5))',
|
|
93
|
-
'Text("B", (1.85 , -2.8))',
|
|
94
|
-
'Text("C", (5.5 , 2.85))',
|
|
95
|
-
'Text("D", (5.5 , 0.85))',
|
|
96
|
-
'Text("C", (5.5 , -1.1))',
|
|
97
|
-
'Text("D", (5.5 , -3.1))',
|
|
98
|
-
];
|
|
99
|
-
const getPropositions = (n) => {
|
|
100
|
-
const res = [];
|
|
101
|
-
res.push({
|
|
102
|
-
id: (0, uuid_1.v4)() + '',
|
|
103
|
-
statement: answer.toTex(),
|
|
104
|
-
isRightAnswer: true,
|
|
105
|
-
});
|
|
106
|
-
for (let i = 0; i < n - 1; i++) {
|
|
107
|
-
let isDuplicate;
|
|
108
|
-
let proposition;
|
|
109
|
-
do {
|
|
110
|
-
proposition = {
|
|
111
|
-
id: (0, uuid_1.v4)() + '',
|
|
112
|
-
statement: (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(answer, new numberNode_1.NumberNode((0, randint_1.randint)(2, 11)))).toTex(),
|
|
113
|
-
isRightAnswer: false,
|
|
114
|
-
};
|
|
115
|
-
isDuplicate = res.some((p) => p.statement === proposition.statement);
|
|
116
|
-
} while (isDuplicate);
|
|
117
|
-
res.push(proposition);
|
|
118
|
-
}
|
|
119
|
-
return (0, shuffle_1.shuffle)(res);
|
|
120
|
-
};
|
|
121
|
-
const question = {
|
|
122
|
-
instruction,
|
|
123
|
-
startStatement,
|
|
124
|
-
answer: answer.toTex(),
|
|
125
|
-
keys: [],
|
|
126
|
-
commands,
|
|
127
|
-
coords: [-2, 8, -5, 5],
|
|
128
|
-
getPropositions,
|
|
129
|
-
};
|
|
130
|
-
return question;
|
|
131
|
-
}
|
|
132
|
-
exports.getProbabilityTree = getProbabilityTree;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"frequencyTable.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/frequencyTable.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI9D,eAAO,MAAM,cAAc,EAAE,QAU5B,CAAC;AAEF,wBAAgB,iBAAiB,IAAI,QAAQ,CAsE5C"}
|