math-exercises 2.2.55 → 2.2.57
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/calcul/proportionality/index.d.ts +1 -0
- package/lib/exercises/math/calcul/proportionality/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/index.js +1 -0
- package/lib/exercises/math/calcul/proportionality/isTableProportional.d.ts +8 -0
- package/lib/exercises/math/calcul/proportionality/isTableProportional.d.ts.map +1 -0
- package/lib/exercises/math/calcul/proportionality/isTableProportional.js +91 -0
- package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.js +0 -1
- package/lib/exercises/math/functions/trinoms/coefficientsIdentification.d.ts +11 -0
- package/lib/exercises/math/functions/trinoms/coefficientsIdentification.d.ts.map +1 -0
- package/lib/exercises/math/functions/trinoms/coefficientsIdentification.js +131 -0
- package/lib/exercises/math/functions/trinoms/index.d.ts +1 -0
- package/lib/exercises/math/functions/trinoms/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/index.js +1 -0
- package/lib/exercises/math/functions/trinoms/summitAbscissFromDevForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/summitAbscissFromDevForm.js +39 -1
- package/lib/exercises/math/geometry/areas/rightTriangleArea.js +2 -2
- package/lib/exercises/math/geometry/areas/triangleArea.js +2 -2
- package/lib/exercises/math/geometry/euclidianConstructions/buildTriangleWithSizes.d.ts +7 -0
- package/lib/exercises/math/geometry/euclidianConstructions/buildTriangleWithSizes.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidianConstructions/buildTriangleWithSizes.js +117 -0
- package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts +2 -0
- package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/index.js +2 -0
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.d.ts +10 -0
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.js +102 -0
- package/lib/exercises/math/geometry/pythagore/pythagore.d.ts +2 -0
- package/lib/exercises/math/geometry/pythagore/pythagore.d.ts.map +1 -1
- package/lib/exercises/math/geometry/pythagore/pythagore.js +4 -3
- package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.d.ts +2 -0
- package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.d.ts.map +1 -1
- package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.js +4 -3
- package/lib/exercises/math/geometry/shapes/basicShapesNaming.d.ts.map +1 -1
- package/lib/exercises/math/geometry/shapes/basicShapesNaming.js +0 -1
- package/lib/exercises/math/geometry/thales/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/thales/index.js +1 -0
- package/lib/exercises/math/geometry/thales/thales.d.ts +7 -0
- package/lib/exercises/math/geometry/thales/thales.d.ts.map +1 -1
- package/lib/exercises/math/geometry/thales/thales.js +1 -1
- package/lib/exercises/math/geometry/thales/thalesCalcul.d.ts +11 -5
- package/lib/exercises/math/geometry/thales/thalesCalcul.d.ts.map +1 -1
- package/lib/exercises/math/geometry/thales/thalesCalcul.js +166 -118
- package/lib/exercises/math/geometry/thales/thalesCalculOld.d.ts +1 -0
- package/lib/exercises/math/geometry/thales/thalesCalculOld.d.ts.map +1 -0
- package/lib/exercises/math/geometry/thales/thalesCalculOld.js +214 -0
- package/lib/exercises/math/percent/index.d.ts +0 -1
- package/lib/exercises/math/percent/index.d.ts.map +1 -1
- package/lib/exercises/math/percent/index.js +0 -1
- package/lib/exercises/math/probaStat/binomial/binomialInequation.d.ts +16 -0
- package/lib/exercises/math/probaStat/binomial/binomialInequation.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/binomial/binomialInequation.js +159 -0
- package/lib/exercises/math/probaStat/binomial/calculateProbaOfBinomialDistribution.d.ts +13 -0
- package/lib/exercises/math/probaStat/binomial/calculateProbaOfBinomialDistribution.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/binomial/calculateProbaOfBinomialDistribution.js +106 -0
- package/lib/exercises/math/probaStat/binomial/expectedValueOfBinomialProba.d.ts +9 -0
- package/lib/exercises/math/probaStat/binomial/expectedValueOfBinomialProba.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/binomial/expectedValueOfBinomialProba.js +89 -0
- package/lib/exercises/math/probaStat/binomial/index.d.ts +5 -0
- package/lib/exercises/math/probaStat/binomial/index.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/binomial/index.js +20 -0
- package/lib/exercises/math/probaStat/binomial/varianceOfBinomialProba.d.ts +9 -0
- package/lib/exercises/math/probaStat/binomial/varianceOfBinomialProba.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/binomial/varianceOfBinomialProba.js +94 -0
- package/lib/exercises/math/probaStat/cardBasicProbas.d.ts +3 -0
- package/lib/exercises/math/probaStat/cardBasicProbas.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/cardBasicProbas.js +3 -2
- package/lib/exercises/math/probaStat/diceBasicProbas.d.ts +1 -0
- package/lib/exercises/math/probaStat/diceBasicProbas.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/diceBasicProbas.js +8 -4
- package/lib/exercises/math/probaStat/index.d.ts +1 -3
- package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/index.js +1 -3
- package/lib/exercises/math/probaStat/issuesCountingForCards.d.ts +2 -0
- package/lib/exercises/math/probaStat/issuesCountingForCards.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/issuesCountingForCards.js +1 -1
- package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts +4 -1
- package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableNoContext.js +17 -5
- package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.js +0 -1
- package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.d.ts +2 -0
- package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.js +4 -1
- package/lib/exercises/math/trigonometry/associatePoint.d.ts +3 -0
- package/lib/exercises/math/trigonometry/associatePoint.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/associatePoint.js +5 -1
- package/lib/exercises/math/trigonometry/trigonometry.js +2 -2
- package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.js +2 -2
- package/lib/exercises/math/trigonometry/trigonometrySideCalcul.js +2 -2
- package/lib/exercises/pc/calibrationCurveOfSolution.d.ts +1 -0
- package/lib/exercises/pc/calibrationCurveOfSolution.d.ts.map +1 -1
- package/lib/exercises/pc/calibrationCurveOfSolution.js +2 -0
- package/lib/exercises/pc/chemicalReactions/stoichiometricReaction.d.ts +6 -1
- package/lib/exercises/pc/chemicalReactions/stoichiometricReaction.d.ts.map +1 -1
- package/lib/exercises/pc/chemicalReactions/stoichiometricReaction.js +1 -1
- package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.d.ts +4 -1
- package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.d.ts.map +1 -1
- package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.js +2 -1
- package/lib/exercises/pc/identifyAtomicMassOrAtomicNb.d.ts +2 -0
- package/lib/exercises/pc/identifyAtomicMassOrAtomicNb.d.ts.map +1 -1
- package/lib/exercises/pc/identifyAtomicMassOrAtomicNb.js +2 -0
- package/lib/exercises/pc/mole/molarMass.js +1 -1
- package/lib/exercises/pc/motion/typeOfAcceleration.d.ts +4 -1
- package/lib/exercises/pc/motion/typeOfAcceleration.d.ts.map +1 -1
- package/lib/exercises/pc/motion/typeOfAcceleration.js +5 -1
- package/lib/exercises/pc/motion/typeOfMovement.d.ts +4 -1
- package/lib/exercises/pc/motion/typeOfMovement.d.ts.map +1 -1
- package/lib/exercises/pc/motion/typeOfMovement.js +1 -1
- package/lib/exercises/pc/recognizeRefractionOrReflectionAngles.d.ts +3 -1
- package/lib/exercises/pc/recognizeRefractionOrReflectionAngles.d.ts.map +1 -1
- package/lib/exercises/pc/recognizeRefractionOrReflectionAngles.js +1 -1
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts +3 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts.map +1 -1
- package/lib/exercises/utils/geogebra/toolBarConstructor.d.ts +4 -0
- package/lib/exercises/utils/geogebra/toolBarConstructor.d.ts.map +1 -1
- package/lib/exercises/utils/geogebra/toolBarConstructor.js +8 -0
- package/lib/exercises/utils/getDistinctQuestions.d.ts.map +1 -1
- package/lib/exercises/utils/getDistinctQuestions.js +11 -4
- package/lib/index.d.ts +94 -26
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/CloudPoints.d.ts +5 -1
- package/lib/math/geometry/CloudPoints.d.ts.map +1 -1
- package/lib/math/geometry/CloudPoints.js +5 -0
- package/lib/math/geometry/line.d.ts +23 -1
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +53 -2
- package/lib/math/geometry/point.d.ts +15 -13
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +28 -12
- package/lib/math/geometry/segment.d.ts +11 -1
- package/lib/math/geometry/segment.d.ts.map +1 -1
- package/lib/math/geometry/segment.js +12 -0
- package/lib/math/geometry/triangle.d.ts +67 -0
- package/lib/math/geometry/triangle.d.ts.map +1 -0
- package/lib/math/geometry/triangle.js +227 -0
- package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.js +0 -2
- package/lib/math/numbers/rationals/rational.d.ts +1 -0
- package/lib/math/numbers/rationals/rational.d.ts.map +1 -1
- package/lib/math/numbers/rationals/rational.js +5 -0
- package/lib/math/polynomials/generalTrinom.d.ts +2 -2
- package/lib/math/polynomials/generalTrinom.d.ts.map +1 -1
- package/lib/math/probability/binomial.d.ts +10 -0
- package/lib/math/probability/binomial.d.ts.map +1 -0
- package/lib/math/probability/binomial.js +30 -0
- package/lib/math/sets/intervals/intervals.d.ts +1 -1
- package/lib/math/systems/generalSystem.d.ts +11 -0
- package/lib/math/systems/generalSystem.d.ts.map +1 -0
- package/lib/math/systems/generalSystem.js +79 -0
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +1 -4
- package/lib/server.js +0 -2
- package/lib/tree/nodes/geometry/pointNode.d.ts +1 -10
- package/lib/tree/nodes/geometry/pointNode.d.ts.map +1 -1
- package/lib/tree/nodes/inequations/inequationNode.js +1 -1
- package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts +2 -11
- package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts.map +1 -1
- package/lib/tree/nodes/node.d.ts +2 -1
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/node.js +1 -0
- package/lib/tree/nodes/nodeConstructor.d.ts +4 -3
- package/lib/tree/nodes/nodeConstructor.d.ts.map +1 -1
- package/lib/tree/nodes/nodeConstructor.js +4 -0
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +20 -8
- package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts +35 -0
- package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts.map +1 -0
- package/lib/tree/nodes/operators/binomialCoefficientNode.js +52 -0
- package/lib/tree/nodes/operators/fractionNode.d.ts +1 -1
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +2 -4
- package/lib/tree/nodes/operators/operatorNode.d.ts +2 -1
- package/lib/tree/nodes/operators/operatorNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/operatorNode.js +1 -0
- package/lib/tree/nodes/sets/intervalNode.d.ts +9 -10
- package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
- package/lib/tree/nodes/sets/intervalNode.js +1 -0
- package/lib/utils/alea/random.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import {
|
|
3
|
+
// Exercise,
|
|
4
|
+
// Proposition,
|
|
5
|
+
// QCMGenerator,
|
|
6
|
+
// Question,
|
|
7
|
+
// QuestionGenerator,
|
|
8
|
+
// VEA,
|
|
9
|
+
// addValidProp,
|
|
10
|
+
// tryToAddWrongProp,
|
|
11
|
+
// } from "../../../../exercises/exercise";
|
|
12
|
+
// import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions";
|
|
13
|
+
// import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor";
|
|
14
|
+
// import { Rational } from "../../../../math/numbers/rationals/rational";
|
|
15
|
+
// import { randint } from "../../../../math/utils/random/randint";
|
|
16
|
+
// import { Node } from "../../../../tree/nodes/node";
|
|
17
|
+
// import { coinFlip } from "../../../../utils/alea/coinFlip";
|
|
18
|
+
// import { shuffle } from "../../../../utils/alea/shuffle";
|
|
19
|
+
// type Identifiers = {
|
|
20
|
+
// sideLengths: number[];
|
|
21
|
+
// rand: number;
|
|
22
|
+
// rand2: number;
|
|
23
|
+
// isAskingC: boolean;
|
|
24
|
+
// xA: number;
|
|
25
|
+
// yA: number;
|
|
26
|
+
// xB: number;
|
|
27
|
+
// yB: number;
|
|
28
|
+
// xC: number;
|
|
29
|
+
// yC: number;
|
|
30
|
+
// factor: number;
|
|
31
|
+
// };
|
|
32
|
+
// const getThales: QuestionGenerator<Identifiers> = () => {
|
|
33
|
+
// const vertices = [];
|
|
34
|
+
// const code = 65 + randint(0, 22); // Générer un code de caractère majuscule aléatoire (A-Z)
|
|
35
|
+
// for (let i = 0; i < 5; i++) vertices.push(String.fromCharCode(code + i));
|
|
36
|
+
// const [xA, yA] = [randint(-10, 11), randint(-10, 11)];
|
|
37
|
+
// let xB, yB, xC, yC;
|
|
38
|
+
// let d1, d2, d3; // distance entre le point A et B
|
|
39
|
+
// let theta = 0; // angle entre AB et AC
|
|
40
|
+
// do {
|
|
41
|
+
// [xB, yB, xC, yC] = [
|
|
42
|
+
// randint(-10, 11),
|
|
43
|
+
// randint(-10, 11),
|
|
44
|
+
// randint(-10, 11),
|
|
45
|
+
// randint(-10, 11),
|
|
46
|
+
// ];
|
|
47
|
+
// d1 = Math.hypot(xB - xA, yB - yA); // Calculer la distance entre A et B
|
|
48
|
+
// d2 = Math.hypot(xC - xA, yC - yA); // Calculer la distance entre A et C
|
|
49
|
+
// theta = Math.acos(
|
|
50
|
+
// ((xB - xA) * (xC - xA) + (yB - yA) * (yC - yA)) / (d1 * d2),
|
|
51
|
+
// );
|
|
52
|
+
// } while (
|
|
53
|
+
// !theta ||
|
|
54
|
+
// theta < 0.35 ||
|
|
55
|
+
// theta > 2.1 ||
|
|
56
|
+
// d1 / d2 > 1.3 ||
|
|
57
|
+
// d1 / d2 < 0.7
|
|
58
|
+
// );
|
|
59
|
+
// d3 = Math.sqrt(d1 ** 2 + d2 ** 2 - 2 * d1 * d2 * Math.cos(theta)); // Calculer la distance entre C et B
|
|
60
|
+
// // CB² = AB² * AC² - 2*AB*AC*cos(theta) : pythagore généralisé
|
|
61
|
+
// const factor = randint(-5, 6, [-2, -1, 0, 1, 2]) / 10; // facteur = AB/AE, Pour que l'affichage soit acceptable, les valeurs de factor sont +- 0.5 0.4 0.3
|
|
62
|
+
// const [xD, yD] = [xA + factor * (xB - xA), yA + factor * (yB - yA)];
|
|
63
|
+
// const [xE, yE] = [xA + factor * (xC - xA), yA + factor * (yC - yA)];
|
|
64
|
+
// const xMin = Math.min(xA, xB, xC, xD, xE);
|
|
65
|
+
// const xMax = Math.max(xA, xB, xC, xD, xE);
|
|
66
|
+
// const yMin = Math.min(yA, yB, yC, yD, yE);
|
|
67
|
+
// const yMax = Math.max(yA, yB, yC, yD, yE);
|
|
68
|
+
// // AB AC BC AD AE
|
|
69
|
+
// const sides = [
|
|
70
|
+
// `${vertices[0]}${vertices[1]}`,
|
|
71
|
+
// `${vertices[0]}${vertices[3]}`,
|
|
72
|
+
// `${vertices[0]}${vertices[2]}`,
|
|
73
|
+
// `${vertices[0]}${vertices[4]}`,
|
|
74
|
+
// `${vertices[1]}${vertices[2]}`,
|
|
75
|
+
// `${vertices[3]}${vertices[4]}`,
|
|
76
|
+
// ];
|
|
77
|
+
// // round pour avoir des valeurs dans N tout en gardant les proportions pour que ça soit cohérent. sides[i] a pour longueur sideLengths[i]
|
|
78
|
+
// const sideLengths = [d1, factor * d1, d2, factor * d2, d3, factor * d3].map(
|
|
79
|
+
// (el) => Math.round(Math.abs(el)),
|
|
80
|
+
// );
|
|
81
|
+
// const rand = randint(0, 3);
|
|
82
|
+
// let rand2 = randint(0, 3, [rand]);
|
|
83
|
+
// if (sideLengths[2 * rand] === sideLengths[2 * rand2])
|
|
84
|
+
// rand2 = randint(0, 3, [rand, rand2]); // condition pour pas prendre 2 longueurs identiques
|
|
85
|
+
// let instruction = `Dans la figure ci-dessous, on a $(${vertices[3]}${vertices[4]})//(${vertices[1]}${vertices[2]})$, `;
|
|
86
|
+
// let statement: Node;
|
|
87
|
+
// let startStatement;
|
|
88
|
+
// const isAskingC = coinFlip();
|
|
89
|
+
// if (isAskingC) {
|
|
90
|
+
// // a/b = c/d on cherche c
|
|
91
|
+
// instruction += `$${sides[2 * rand]} = ${sideLengths[2 * rand]}$, $${
|
|
92
|
+
// sides[2 * rand + 1]
|
|
93
|
+
// } = ${sideLengths[2 * rand + 1]}$, $${sides[2 * rand2]} = ${
|
|
94
|
+
// sideLengths[2 * rand2]
|
|
95
|
+
// }$. Déterminer $${sides[2 * rand2 + 1]}$.`;
|
|
96
|
+
// startStatement = `${sides[2 * rand2 + 1]}`;
|
|
97
|
+
// statement = new Rational(
|
|
98
|
+
// sideLengths[2 * rand2] * sideLengths[2 * rand + 1],
|
|
99
|
+
// sideLengths[2 * rand],
|
|
100
|
+
// )
|
|
101
|
+
// .simplify()
|
|
102
|
+
// .toTree();
|
|
103
|
+
// } else {
|
|
104
|
+
// // a/b = c/d on cherche d
|
|
105
|
+
// instruction += `$${sides[2 * rand]} = ${sideLengths[2 * rand]}$, $${
|
|
106
|
+
// sides[2 * rand + 1]
|
|
107
|
+
// } = ${sideLengths[2 * rand + 1]}$, $${sides[2 * rand2 + 1]} = ${
|
|
108
|
+
// sideLengths[2 * rand2 + 1]
|
|
109
|
+
// }$. Déterminer $${sides[2 * rand2]}$.`;
|
|
110
|
+
// startStatement = `${sides[2 * rand2]}`;
|
|
111
|
+
// statement = new Rational(
|
|
112
|
+
// sideLengths[2 * rand2 + 1] * sideLengths[2 * rand],
|
|
113
|
+
// sideLengths[2 * rand + 1],
|
|
114
|
+
// )
|
|
115
|
+
// .simplify()
|
|
116
|
+
// .toTree();
|
|
117
|
+
// }
|
|
118
|
+
// const commands = [
|
|
119
|
+
// `${vertices[0]} = Point({${xA}, ${yA}})`,
|
|
120
|
+
// `${vertices[1]} = Point({${xB}, ${yB}})`,
|
|
121
|
+
// `${vertices[2]} = Point({${xC}, ${yC}})`,
|
|
122
|
+
// `${vertices[3]} = Point(${vertices[0]}, Vector(${factor}Vector(${vertices[0]},${vertices[1]})))`,
|
|
123
|
+
// `${vertices[4]} = Intersect(Line(${vertices[3]}, Line(${vertices[1]}, ${vertices[2]})) , Line(${vertices[0]}, ${vertices[2]}))`,
|
|
124
|
+
// `l = Segment(${vertices[0]}, ${vertices[1]})`,
|
|
125
|
+
// `i = Segment(${vertices[0]}, ${vertices[2]})`,
|
|
126
|
+
// `j = Segment(${vertices[1]}, ${vertices[2]})`,
|
|
127
|
+
// `k = Segment(${vertices[3]}, ${vertices[4]})`,
|
|
128
|
+
// `If(${factor} < 0, Segment(${vertices[0]}, ${vertices[3]}))`,
|
|
129
|
+
// `If(${factor} < 0, Segment(${vertices[0]}, ${vertices[4]}))`,
|
|
130
|
+
// `ShowLabel(${vertices[0]}, true)`,
|
|
131
|
+
// `ShowLabel(${vertices[1]}, true)`,
|
|
132
|
+
// `ShowLabel(${vertices[2]}, true)`,
|
|
133
|
+
// `ShowLabel(${vertices[3]}, true)`,
|
|
134
|
+
// `ShowLabel(${vertices[4]}, true)`,
|
|
135
|
+
// ];
|
|
136
|
+
// const ggb = new GeogebraConstructor({
|
|
137
|
+
// commands,
|
|
138
|
+
// hideAxes: true,
|
|
139
|
+
// hideGrid: true,
|
|
140
|
+
// });
|
|
141
|
+
// const answer = statement.toTex();
|
|
142
|
+
// const question: Question<Identifiers> = {
|
|
143
|
+
// instruction,
|
|
144
|
+
// startStatement,
|
|
145
|
+
// answer,
|
|
146
|
+
// keys: [],
|
|
147
|
+
// ggbOptions: ggb.getOptions({
|
|
148
|
+
// coords: [xMin - 1, xMax + 1, yMin - 1, yMax + 1],
|
|
149
|
+
// }),
|
|
150
|
+
// answerFormat: "tex",
|
|
151
|
+
// identifiers: {
|
|
152
|
+
// isAskingC,
|
|
153
|
+
// rand,
|
|
154
|
+
// rand2,
|
|
155
|
+
// sideLengths,
|
|
156
|
+
// xA,
|
|
157
|
+
// yA,
|
|
158
|
+
// xB,
|
|
159
|
+
// yB,
|
|
160
|
+
// xC,
|
|
161
|
+
// yC,
|
|
162
|
+
// factor,
|
|
163
|
+
// },
|
|
164
|
+
// };
|
|
165
|
+
// return question;
|
|
166
|
+
// };
|
|
167
|
+
// const getPropositions: QCMGenerator<Identifiers> = (n, { answer }) => {
|
|
168
|
+
// const propositions: Proposition[] = [];
|
|
169
|
+
// addValidProp(propositions, answer);
|
|
170
|
+
// while (propositions.length < n) {
|
|
171
|
+
// tryToAddWrongProp(
|
|
172
|
+
// propositions,
|
|
173
|
+
// new Rational(randint(2, 30), randint(2, 30)).simplify().toTree().toTex(),
|
|
174
|
+
// );
|
|
175
|
+
// }
|
|
176
|
+
// return shuffle(propositions);
|
|
177
|
+
// };
|
|
178
|
+
// const isAnswerValid: VEA<Identifiers> = (
|
|
179
|
+
// ans,
|
|
180
|
+
// { isAskingC, rand, rand2, sideLengths },
|
|
181
|
+
// ) => {
|
|
182
|
+
// let answer: Node;
|
|
183
|
+
// if (isAskingC)
|
|
184
|
+
// answer = new Rational(
|
|
185
|
+
// sideLengths[2 * rand2] * sideLengths[2 * rand + 1],
|
|
186
|
+
// sideLengths[2 * rand],
|
|
187
|
+
// )
|
|
188
|
+
// .simplify()
|
|
189
|
+
// .toTree();
|
|
190
|
+
// else
|
|
191
|
+
// answer = new Rational(
|
|
192
|
+
// sideLengths[2 * rand2 + 1] * sideLengths[2 * rand],
|
|
193
|
+
// sideLengths[2 * rand + 1],
|
|
194
|
+
// )
|
|
195
|
+
// .simplify()
|
|
196
|
+
// .toTree();
|
|
197
|
+
// const texs = answer.toAllValidTexs({ allowFractionToDecimal: true });
|
|
198
|
+
// return texs.includes(ans);
|
|
199
|
+
// };
|
|
200
|
+
// export const thalesCalcul: Exercise<Identifiers> = {
|
|
201
|
+
// id: "thalesCalcul",
|
|
202
|
+
// connector: "=",
|
|
203
|
+
// label: "Utiliser le théoreme de Thalès pour faire des calculs",
|
|
204
|
+
// levels: ["5ème", "4ème", "3ème", "2nde"],
|
|
205
|
+
// isSingleStep: false,
|
|
206
|
+
// sections: ["Théorème de Thalès", "Géométrie euclidienne"],
|
|
207
|
+
// generator: (nb: number) => getDistinctQuestions(getThales, nb),
|
|
208
|
+
// qcmTimer: 60,
|
|
209
|
+
// freeTimer: 60,
|
|
210
|
+
// getPropositions,
|
|
211
|
+
// isAnswerValid,
|
|
212
|
+
// hasGeogebra: true,
|
|
213
|
+
// subject: "Mathématiques",
|
|
214
|
+
// };
|
|
@@ -6,7 +6,6 @@ export * from "./reciprocalPercentage";
|
|
|
6
6
|
export * from "./percentToDecimal";
|
|
7
7
|
export * from "./valuePercent";
|
|
8
8
|
export * from "./findProportion";
|
|
9
|
-
export * from "./isTableProportional";
|
|
10
9
|
export * from "./cmToEvolution";
|
|
11
10
|
export * from "./htToTTC";
|
|
12
11
|
export * from "./ttcToHT";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC"}
|
|
@@ -22,7 +22,6 @@ __exportStar(require("./reciprocalPercentage"), exports);
|
|
|
22
22
|
__exportStar(require("./percentToDecimal"), exports);
|
|
23
23
|
__exportStar(require("./valuePercent"), exports);
|
|
24
24
|
__exportStar(require("./findProportion"), exports);
|
|
25
|
-
__exportStar(require("./isTableProportional"), exports);
|
|
26
25
|
__exportStar(require("./cmToEvolution"), exports);
|
|
27
26
|
__exportStar(require("./htToTTC"), exports);
|
|
28
27
|
__exportStar(require("./ttcToHT"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor";
|
|
3
|
+
import { IntervalNodeIdentifiers } from "../../../../tree/nodes/sets/intervalNode";
|
|
4
|
+
type Identifiers = {
|
|
5
|
+
n: number;
|
|
6
|
+
p: NodeIdentifiers;
|
|
7
|
+
interval: IntervalNodeIdentifiers;
|
|
8
|
+
type: number;
|
|
9
|
+
isSentence: boolean;
|
|
10
|
+
};
|
|
11
|
+
type Options = {
|
|
12
|
+
instructionType: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const binomialInequation: Exercise<Identifiers, Options>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=binomialInequation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binomialInequation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/binomial/binomialInequation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,0BAA0B,CAAC;AAUlC,OAAO,EAEL,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAM1C,OAAO,EAEL,uBAAuB,EACxB,MAAM,oCAAoC,CAAC;AAK5C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,eAAe,CAAC;IACnB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAgKF,KAAK,OAAO,GAAG;IACb,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAeF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB7D,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.binomialInequation = void 0;
|
|
4
|
+
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const numberVEA_1 = require("../../../../exercises/vea/numberVEA");
|
|
7
|
+
const rational_1 = require("../../../../math/numbers/rationals/rational");
|
|
8
|
+
const binomial_1 = require("../../../../math/probability/binomial");
|
|
9
|
+
const randfloat_1 = require("../../../../math/utils/random/randfloat");
|
|
10
|
+
const randint_1 = require("../../../../math/utils/random/randint");
|
|
11
|
+
const round_1 = require("../../../../math/utils/round");
|
|
12
|
+
const nodeConstructor_1 = require("../../../../tree/nodes/nodeConstructor");
|
|
13
|
+
const infiniteNode_1 = require("../../../../tree/nodes/numbers/infiniteNode");
|
|
14
|
+
const closure_1 = require("../../../../tree/nodes/sets/closure");
|
|
15
|
+
const intervalNode_1 = require("../../../../tree/nodes/sets/intervalNode");
|
|
16
|
+
const coinFlip_1 = require("../../../../utils/alea/coinFlip");
|
|
17
|
+
const random_1 = require("../../../../utils/alea/random");
|
|
18
|
+
const getPropositions = (n, { answer }) => {
|
|
19
|
+
const propositions = [];
|
|
20
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
21
|
+
while (propositions.length < n) {
|
|
22
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, randfloat_1.randfloat)(0, 1, 2).frenchify());
|
|
23
|
+
}
|
|
24
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
25
|
+
};
|
|
26
|
+
const getAnswer = (identifiers) => {
|
|
27
|
+
const binomial = new binomial_1.Binomial(identifiers.n, nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.p));
|
|
28
|
+
const a = nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.interval.leftChild).evaluate();
|
|
29
|
+
const b = nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.interval.rightChild).evaluate();
|
|
30
|
+
const isStrict = identifiers.interval.closure === closure_1.ClosureType.OO;
|
|
31
|
+
const ans = identifiers.type === 1
|
|
32
|
+
? binomial.inf(isStrict ? b - 1 : b)
|
|
33
|
+
: identifiers.type === 2
|
|
34
|
+
? binomial.sup(isStrict ? a + 1 : a)
|
|
35
|
+
: binomial.ineq(isStrict ? a + 1 : a, isStrict ? b - 1 : b);
|
|
36
|
+
return (0, round_1.round)(ans, 2).frenchify();
|
|
37
|
+
};
|
|
38
|
+
const getInstruction = (identifiers, opts) => {
|
|
39
|
+
//au plus : X<=k
|
|
40
|
+
//moins de : X<k
|
|
41
|
+
//au moins: X >= k
|
|
42
|
+
//pus de : X>k
|
|
43
|
+
//entre : a <= X <= b (strict exclus)
|
|
44
|
+
const pNode = nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.p);
|
|
45
|
+
const interval = nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.interval);
|
|
46
|
+
const isStrict = interval.closure === closure_1.ClosureType.OO;
|
|
47
|
+
let sentence = "";
|
|
48
|
+
switch (identifiers.type) {
|
|
49
|
+
case 1:
|
|
50
|
+
sentence = isStrict
|
|
51
|
+
? `moins de $${interval.b.toTex()}$`
|
|
52
|
+
: `au plus $${interval.b.toTex()}$`;
|
|
53
|
+
break;
|
|
54
|
+
case 2:
|
|
55
|
+
sentence = isStrict
|
|
56
|
+
? `plus de $${interval.a.toTex()}$`
|
|
57
|
+
: `au moins $${interval.a.toTex()}$`;
|
|
58
|
+
break;
|
|
59
|
+
case 3:
|
|
60
|
+
sentence = `entre $${interval.a.toTex()}$ et $${interval.b.toTex()}$`;
|
|
61
|
+
}
|
|
62
|
+
return `Soit $X$ une variable aléatoire qui suit une loi binomiale de paramètres $n = ${identifiers.n}$ et $p = ${pNode.toTex()}$.
|
|
63
|
+
|
|
64
|
+
${identifiers.isSentence
|
|
65
|
+
? `Quelle est la probabilité d'obtenir ${sentence} succès ? Arrondir à $10^{-2}$ près.`
|
|
66
|
+
: `Calculer en donnant la réponse à $10^{-2}$ près :
|
|
67
|
+
|
|
68
|
+
$$
|
|
69
|
+
${interval.toInequality("P(X)".toTree()).toTex()}
|
|
70
|
+
$$`}`;
|
|
71
|
+
};
|
|
72
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
73
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
74
|
+
const getKeys = (identifiers) => {
|
|
75
|
+
return [];
|
|
76
|
+
};
|
|
77
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
78
|
+
return (0, numberVEA_1.numberVEA)(ans, answer);
|
|
79
|
+
};
|
|
80
|
+
const getBinomialInequationQuestion = (opts) => {
|
|
81
|
+
const n = (0, random_1.random)([(0, randint_1.randint)(4, 10), 5 * (0, randint_1.randint)(3, 10)]);
|
|
82
|
+
const p = (0, random_1.random)([
|
|
83
|
+
(0, randfloat_1.randfloat)(0.01, 0.99, 2).toTree(),
|
|
84
|
+
rational_1.RationalConstructor.randomIrreductibleProba().toTree(),
|
|
85
|
+
]);
|
|
86
|
+
const isSentence = !opts || opts?.instructionType === "Toutes"
|
|
87
|
+
? (0, coinFlip_1.coinFlip)()
|
|
88
|
+
: opts.instructionType === "Uniquement sous forme de phrase";
|
|
89
|
+
const type = (0, randint_1.randint)(1, 4);
|
|
90
|
+
let interval;
|
|
91
|
+
let isStrict = isSentence && type === 3 ? false : (0, coinFlip_1.coinFlip)();
|
|
92
|
+
switch (type) {
|
|
93
|
+
case 1:
|
|
94
|
+
//P(X< <= b)
|
|
95
|
+
interval = new intervalNode_1.IntervalNode(infiniteNode_1.MinusInfinityNode, (0, randint_1.randint)(isStrict ? 2 : 1, isStrict ? n + 1 : n).toTree(), isStrict ? closure_1.ClosureType.OO : closure_1.ClosureType.OF);
|
|
96
|
+
break;
|
|
97
|
+
case 2:
|
|
98
|
+
//P(X > >= a)
|
|
99
|
+
interval = new intervalNode_1.IntervalNode((0, randint_1.randint)(isStrict ? 0 : 1, isStrict ? n - 1 : n).toTree(), infiniteNode_1.PlusInfinityNode, isStrict ? closure_1.ClosureType.OO : closure_1.ClosureType.FO);
|
|
100
|
+
break;
|
|
101
|
+
case 3:
|
|
102
|
+
default:
|
|
103
|
+
//P(a < X <b)
|
|
104
|
+
let a, b;
|
|
105
|
+
do {
|
|
106
|
+
a = (0, randint_1.randint)(isStrict ? 0 : 1, isStrict ? n - 1 : n);
|
|
107
|
+
b = (0, randint_1.randint)(a + 1, isStrict ? n + 1 : n);
|
|
108
|
+
} while (!b || Math.abs(b - a) < 2 || (isStrict && Math.abs(b - a) < 3));
|
|
109
|
+
interval = new intervalNode_1.IntervalNode(a.toTree(), b.toTree(), isStrict ? closure_1.ClosureType.OO : closure_1.ClosureType.FF);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
const identifiers = {
|
|
113
|
+
n,
|
|
114
|
+
p: p.toIdentifiers(),
|
|
115
|
+
interval: interval.toIdentifiers(),
|
|
116
|
+
type,
|
|
117
|
+
isSentence,
|
|
118
|
+
};
|
|
119
|
+
const question = {
|
|
120
|
+
answer: getAnswer(identifiers),
|
|
121
|
+
instruction: getInstruction(identifiers, opts),
|
|
122
|
+
keys: getKeys(identifiers),
|
|
123
|
+
answerFormat: "tex",
|
|
124
|
+
identifiers,
|
|
125
|
+
// hint: getHint(identifiers),
|
|
126
|
+
// correction: getCorrection(identifiers),
|
|
127
|
+
};
|
|
128
|
+
return question;
|
|
129
|
+
};
|
|
130
|
+
//>a, <a, [a,b], au plus a, au moins b, plus de, moins de,
|
|
131
|
+
const options = [
|
|
132
|
+
{
|
|
133
|
+
id: "instructionType",
|
|
134
|
+
label: "Types de consignes",
|
|
135
|
+
target: exercise_1.GeneratorOptionTarget.instruction,
|
|
136
|
+
type: exercise_1.GeneratorOptionType.select,
|
|
137
|
+
values: [
|
|
138
|
+
"Toutes",
|
|
139
|
+
"Uniquement sous forme de phrase",
|
|
140
|
+
"Uniquement sous forme mathématique",
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
exports.binomialInequation = {
|
|
145
|
+
id: "binomialInequation",
|
|
146
|
+
connector: "\\iff",
|
|
147
|
+
label: "Calculer une probabilité binomiale du type $P(x) \\leq a$, $P(X)\\geq a$ ou $a\\leq P(X)\\leq b$",
|
|
148
|
+
isSingleStep: true,
|
|
149
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getBinomialInequationQuestion(opts), nb),
|
|
150
|
+
qcmTimer: 60,
|
|
151
|
+
freeTimer: 60,
|
|
152
|
+
getPropositions,
|
|
153
|
+
isAnswerValid,
|
|
154
|
+
subject: "Mathématiques",
|
|
155
|
+
// getHint,
|
|
156
|
+
// getCorrection,
|
|
157
|
+
getAnswer,
|
|
158
|
+
options,
|
|
159
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
exerciseVars: ExerciseVars;
|
|
4
|
+
};
|
|
5
|
+
type ExerciseVars = {
|
|
6
|
+
n: number;
|
|
7
|
+
k: number;
|
|
8
|
+
a: number;
|
|
9
|
+
b: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const calculateProbaOfBinomialDistribution: Exercise<Identifiers>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=calculateProbaOfBinomialDistribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateProbaOfBinomialDistribution.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/binomial/calculateProbaOfBinomialDistribution.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqHF,eAAO,MAAM,oCAAoC,EAAE,QAAQ,CAAC,WAAW,CActE,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateProbaOfBinomialDistribution = void 0;
|
|
4
|
+
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const rational_1 = require("../../../../math/numbers/rationals/rational");
|
|
7
|
+
const combination_1 = require("../../../../math/utils/combinatorics/combination");
|
|
8
|
+
const randfloat_1 = require("../../../../math/utils/random/randfloat");
|
|
9
|
+
const randint_1 = require("../../../../math/utils/random/randint");
|
|
10
|
+
const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
|
|
11
|
+
const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
|
|
12
|
+
const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
|
|
13
|
+
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
14
|
+
const getCalculateProbaOfBinomialDistributionQuestion = () => {
|
|
15
|
+
const exercise = generateExercise();
|
|
16
|
+
const p = new rational_1.Rational(exercise.a, exercise.b);
|
|
17
|
+
const correctAns = new numberNode_1.NumberNode(getCorrectAnswer(exercise.n, p.value, exercise.k));
|
|
18
|
+
const question = {
|
|
19
|
+
answer: correctAns.toTex(),
|
|
20
|
+
instruction: `Soit $X$ une variable aléatoire qui suit une loi binomiale de paramètres $n=${exercise.n}$ et $p=${p
|
|
21
|
+
.toTree()
|
|
22
|
+
.simplify()
|
|
23
|
+
.toTex()}$. Donner une valeur arrondie au centième de $P(X=${exercise.k}).$`,
|
|
24
|
+
keys: [],
|
|
25
|
+
answerFormat: "tex",
|
|
26
|
+
hint: `Si $X$ est une variable aléatoire qui suit une loi binomiale de paramètres $n$ et $p$, alors on a :
|
|
27
|
+
|
|
28
|
+
$P(X=k) = \\binom{n}{k} p^k (1-p)^{n-k}$`,
|
|
29
|
+
correction: `Si $X$ est une variable aléatoire qui suit une loi binomiale de paramètres $n$ et $p$, alors on a :
|
|
30
|
+
|
|
31
|
+
$P(X=k) = \\binom{n}{k} p^k (1-p)^{n-k}$
|
|
32
|
+
|
|
33
|
+
Ici, on a donc :
|
|
34
|
+
|
|
35
|
+
${(0, alignTex_1.alignTex)([
|
|
36
|
+
[
|
|
37
|
+
`P(X=${exercise.k})`,
|
|
38
|
+
"=",
|
|
39
|
+
`\\binom{${exercise.n}}{${exercise.k}} ${new multiplyNode_1.MultiplyNode(new powerNode_1.PowerNode(p.toTree(), exercise.k.toTree()), new powerNode_1.PowerNode(new rational_1.Rational(exercise.b - exercise.a, exercise.b).toTree(), (exercise.n - exercise.k).toTree())).toTex()}`,
|
|
40
|
+
],
|
|
41
|
+
["", "\\approx", correctAns.toTex()],
|
|
42
|
+
])}`,
|
|
43
|
+
identifiers: { exerciseVars: exercise },
|
|
44
|
+
};
|
|
45
|
+
return question;
|
|
46
|
+
};
|
|
47
|
+
const getPropositions = (n, { answer, exerciseVars }) => {
|
|
48
|
+
const propositions = [];
|
|
49
|
+
const p = exerciseVars.a / exerciseVars.b;
|
|
50
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
51
|
+
generatePropositions(exerciseVars.n, p, exerciseVars.k).forEach((value) => (0, exercise_1.tryToAddWrongProp)(propositions, value));
|
|
52
|
+
const correctAns = getCorrectAnswer(n, p, exerciseVars.k);
|
|
53
|
+
let random;
|
|
54
|
+
while (propositions.length < n) {
|
|
55
|
+
random = new numberNode_1.NumberNode(+(correctAns + (0, randfloat_1.randfloat)(0.1, 0.6, 2, [correctAns])).toFixed(2));
|
|
56
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, random.toTex());
|
|
57
|
+
}
|
|
58
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
59
|
+
};
|
|
60
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
61
|
+
return ans === answer;
|
|
62
|
+
};
|
|
63
|
+
const generatePropositions = (n, p, k) => {
|
|
64
|
+
const kChooseN = (0, combination_1.combinations)(k, n);
|
|
65
|
+
const firstProposition = new numberNode_1.NumberNode(+(Math.pow(p, n - k) * Math.pow(1 - p, k)).toFixed(2));
|
|
66
|
+
const secondProposition = new numberNode_1.NumberNode(+(Math.pow(p, n) * Math.pow(1 - p, k)).toFixed(2));
|
|
67
|
+
const thirdProposition = new numberNode_1.NumberNode(+(kChooseN * Math.pow(p, k)).toFixed(2));
|
|
68
|
+
return [
|
|
69
|
+
firstProposition.toTex(),
|
|
70
|
+
secondProposition.toTex(),
|
|
71
|
+
thirdProposition.toTex(),
|
|
72
|
+
].filter((value) => +value !== 0);
|
|
73
|
+
};
|
|
74
|
+
const getCorrectAnswer = (n, p, k) => {
|
|
75
|
+
const kChooseN = (0, combination_1.combinations)(k, n);
|
|
76
|
+
return +(kChooseN * Math.pow(p, k) * Math.pow(1 - p, n - k)).toFixed(2);
|
|
77
|
+
};
|
|
78
|
+
const generateExercise = () => {
|
|
79
|
+
let n;
|
|
80
|
+
let k;
|
|
81
|
+
let a;
|
|
82
|
+
let b;
|
|
83
|
+
let correctAns;
|
|
84
|
+
do {
|
|
85
|
+
n = (0, randint_1.randint)(2, 9);
|
|
86
|
+
k = (0, randint_1.randint)(1, n);
|
|
87
|
+
b = (0, randint_1.randint)(2, 11);
|
|
88
|
+
a = (0, randint_1.randint)(1, b);
|
|
89
|
+
correctAns = getCorrectAnswer(n, a / b, k);
|
|
90
|
+
} while (correctAns === 0);
|
|
91
|
+
return { n, k, a, b };
|
|
92
|
+
};
|
|
93
|
+
exports.calculateProbaOfBinomialDistribution = {
|
|
94
|
+
id: "calculateProbaOfBinomialDistribution",
|
|
95
|
+
label: "Calculer une probabilité avec la loi binomiale",
|
|
96
|
+
levels: ["TermTech"],
|
|
97
|
+
isSingleStep: true,
|
|
98
|
+
sections: ["Probabilités"],
|
|
99
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getCalculateProbaOfBinomialDistributionQuestion, nb),
|
|
100
|
+
qcmTimer: 60,
|
|
101
|
+
freeTimer: 60,
|
|
102
|
+
getPropositions,
|
|
103
|
+
isAnswerValid,
|
|
104
|
+
subject: "Mathématiques",
|
|
105
|
+
hasHintAndCorrection: true,
|
|
106
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
nX: number;
|
|
4
|
+
a: number;
|
|
5
|
+
b: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const expectedValueOfBinomialProba: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=expectedValueOfBinomialProba.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expectedValueOfBinomialProba.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/binomial/expectedValueOfBinomialProba.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiFF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAc9D,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.expectedValueOfBinomialProba = void 0;
|
|
4
|
+
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const rational_1 = require("../../../../math/numbers/rationals/rational");
|
|
7
|
+
const randint_1 = require("../../../../math/utils/random/randint");
|
|
8
|
+
const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
|
|
9
|
+
const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
|
|
10
|
+
const substractNode_1 = require("../../../../tree/nodes/operators/substractNode");
|
|
11
|
+
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
12
|
+
const getExpectedValueOfBinomialProbaQuestion = () => {
|
|
13
|
+
const nX = (0, randint_1.randint)(1, 9);
|
|
14
|
+
const b = (0, randint_1.randint)(2, 11);
|
|
15
|
+
const a = (0, randint_1.randint)(1, b);
|
|
16
|
+
const p = new rational_1.Rational(a, b);
|
|
17
|
+
const node = getCorrectAnswer(nX, p);
|
|
18
|
+
const answer = node.toTex();
|
|
19
|
+
const question = {
|
|
20
|
+
answer,
|
|
21
|
+
instruction: `Soit $X$ une variable aléatoire qui suit une loi binomiale de paramètres $n=${nX}$ et $p=${p
|
|
22
|
+
.toTree()
|
|
23
|
+
.simplify()
|
|
24
|
+
.toTex()}$. Calculez l'espérance de $X$.`,
|
|
25
|
+
keys: [],
|
|
26
|
+
answerFormat: "tex",
|
|
27
|
+
identifiers: { nX, a, b },
|
|
28
|
+
hint: `L'espérance d'une variable aléatoire $X$ qui suit une loi binomiale de paramètres $n$ et $p$ est donnée par $E(X) = np$.`,
|
|
29
|
+
correction: `L'espérance d'une variable aléatoire $X$ qui suit une loi binomiale de paramètres $n$ et $p$ est donnée par $E(X) = np$.
|
|
30
|
+
|
|
31
|
+
Ici, on a donc :
|
|
32
|
+
|
|
33
|
+
${(0, alignTex_1.alignTex)([
|
|
34
|
+
["E(X)", "=", new multiplyNode_1.MultiplyNode(nX.toTree(), p.toTree()).toTex()],
|
|
35
|
+
["", "=", answer],
|
|
36
|
+
])}`,
|
|
37
|
+
};
|
|
38
|
+
return question;
|
|
39
|
+
};
|
|
40
|
+
const getPropositions = (n, { answer, nX, a, b }) => {
|
|
41
|
+
const propositions = [];
|
|
42
|
+
const p = new rational_1.Rational(a, b);
|
|
43
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
44
|
+
generatePropositions(nX, p).forEach((value) => (0, exercise_1.tryToAddWrongProp)(propositions, value));
|
|
45
|
+
let random;
|
|
46
|
+
while (propositions.length < n) {
|
|
47
|
+
random = rational_1.RationalConstructor.randomIrreductible(10).toTree();
|
|
48
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, random.toTex());
|
|
49
|
+
}
|
|
50
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
51
|
+
};
|
|
52
|
+
const isAnswerValid = (ans, { nX, a, b }) => {
|
|
53
|
+
const p = new rational_1.Rational(a, b);
|
|
54
|
+
const correctAns = getCorrectAnswer(nX, p);
|
|
55
|
+
return correctAns
|
|
56
|
+
.toAllValidTexs({ allowFractionToDecimal: true })
|
|
57
|
+
.includes(ans);
|
|
58
|
+
};
|
|
59
|
+
const generatePropositions = (n, p) => {
|
|
60
|
+
const pTree = p.toTree().simplify();
|
|
61
|
+
const oneMinusP = new substractNode_1.SubstractNode(new numberNode_1.NumberNode(1), pTree).simplify();
|
|
62
|
+
const nNode = new numberNode_1.NumberNode(n);
|
|
63
|
+
const firstProposition = pTree;
|
|
64
|
+
const secondProposition = new multiplyNode_1.MultiplyNode(nNode, new multiplyNode_1.MultiplyNode(pTree, oneMinusP).simplify()).simplify();
|
|
65
|
+
const thirdProposition = new multiplyNode_1.MultiplyNode(nNode, oneMinusP).simplify();
|
|
66
|
+
return [
|
|
67
|
+
firstProposition.toTex(),
|
|
68
|
+
secondProposition.toTex(),
|
|
69
|
+
thirdProposition.toTex(),
|
|
70
|
+
];
|
|
71
|
+
};
|
|
72
|
+
const getCorrectAnswer = (n, p) => {
|
|
73
|
+
const nNode = new numberNode_1.NumberNode(n);
|
|
74
|
+
return new multiplyNode_1.MultiplyNode(nNode, p.toTree().simplify()).simplify();
|
|
75
|
+
};
|
|
76
|
+
exports.expectedValueOfBinomialProba = {
|
|
77
|
+
id: "expectedValueOfBinomialProba",
|
|
78
|
+
label: "Calcul de l'espérance d'une loi binomiale",
|
|
79
|
+
levels: ["TermTech"],
|
|
80
|
+
isSingleStep: true,
|
|
81
|
+
sections: ["Probabilités"],
|
|
82
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getExpectedValueOfBinomialProbaQuestion, nb),
|
|
83
|
+
qcmTimer: 60,
|
|
84
|
+
freeTimer: 60,
|
|
85
|
+
getPropositions,
|
|
86
|
+
isAnswerValid,
|
|
87
|
+
subject: "Mathématiques",
|
|
88
|
+
hasHintAndCorrection: true,
|
|
89
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/binomial/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC"}
|