math-exercises 3.0.207 → 3.0.209
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/arithmetic/congruenceBasicComputation.d.ts +8 -0
- package/lib/exercises/math/arithmetic/congruenceBasicComputation.d.ts.map +1 -0
- package/lib/exercises/math/arithmetic/congruenceBasicComputation.js +93 -0
- package/lib/exercises/math/arithmetic/index.d.ts +2 -0
- package/lib/exercises/math/arithmetic/index.d.ts.map +1 -0
- package/lib/exercises/math/arithmetic/index.js +1 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.js +15 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +15 -0
- package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.d.ts.map +1 -1
- package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.js +8 -7
- package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.js +14 -13
- package/lib/exercises/math/functions/logarithm/log10Simplifying.d.ts.map +1 -1
- package/lib/exercises/math/functions/logarithm/log10Simplifying.js +72 -33
- package/lib/exercises/math/functions/logarithm/logEquation.d.ts.map +1 -1
- package/lib/exercises/math/functions/logarithm/logEquation.js +40 -2
- package/lib/exercises/math/functions/logarithm/logPowerEquation.d.ts.map +1 -1
- package/lib/exercises/math/functions/logarithm/logPowerEquation.js +55 -6
- package/lib/exercises/math/functions/logarithm/logSimplifiying.d.ts.map +1 -1
- package/lib/exercises/math/functions/logarithm/logSimplifiying.js +45 -5
- package/lib/exercises/math/index.d.ts +1 -0
- package/lib/exercises/math/index.d.ts.map +1 -1
- package/lib/exercises/math/index.js +1 -0
- package/lib/exercises/math/probaStat/density/findParamToMakeDensity.d.ts +8 -0
- package/lib/exercises/math/probaStat/density/findParamToMakeDensity.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/density/findParamToMakeDensity.js +127 -0
- package/lib/exercises/math/probaStat/density/index.d.ts +2 -0
- package/lib/exercises/math/probaStat/density/index.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/density/index.js +1 -0
- package/lib/exercises/math/probaStat/exponential/exponentialLawAverage.d.ts +7 -0
- package/lib/exercises/math/probaStat/exponential/exponentialLawAverage.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/exponential/exponentialLawAverage.js +95 -0
- package/lib/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.d.ts +9 -0
- package/lib/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.js +115 -0
- package/lib/exercises/math/probaStat/exponential/exponentialLawComputeProba.d.ts +8 -0
- package/lib/exercises/math/probaStat/exponential/exponentialLawComputeProba.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/exponential/exponentialLawComputeProba.js +110 -0
- package/lib/exercises/math/probaStat/exponential/index.d.ts +4 -0
- package/lib/exercises/math/probaStat/exponential/index.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/exponential/index.js +3 -0
- package/lib/exercises/math/probaStat/geometric/geometricLawAverage.d.ts +8 -0
- package/lib/exercises/math/probaStat/geometric/geometricLawAverage.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/geometric/geometricLawAverage.js +124 -0
- package/lib/exercises/math/probaStat/geometric/geometricLawComputeProba.d.ts +9 -0
- package/lib/exercises/math/probaStat/geometric/geometricLawComputeProba.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/geometric/geometricLawComputeProba.js +121 -0
- package/lib/exercises/math/probaStat/geometric/index.d.ts +3 -0
- package/lib/exercises/math/probaStat/geometric/index.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/geometric/index.js +2 -0
- package/lib/exercises/math/probaStat/index.d.ts +4 -0
- package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/index.js +4 -0
- package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.js +15 -0
- package/lib/exercises/math/probaStat/uniform/index.d.ts +3 -0
- package/lib/exercises/math/probaStat/uniform/index.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/uniform/index.js +2 -0
- package/lib/exercises/math/probaStat/uniform/uniformAverage.d.ts +8 -0
- package/lib/exercises/math/probaStat/uniform/uniformAverage.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/uniform/uniformAverage.js +100 -0
- package/lib/exercises/math/probaStat/uniform/uniformLawComputeProba.d.ts +10 -0
- package/lib/exercises/math/probaStat/uniform/uniformLawComputeProba.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/uniform/uniformLawComputeProba.js +105 -0
- package/lib/index.d.ts +29 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/latexTester.js +1 -0
- package/lib/tests/pdfs/formatMdToLatex.js +1 -1
- package/lib/tree/nodes/functions/log10Node.d.ts +1 -0
- package/lib/tree/nodes/functions/log10Node.d.ts.map +1 -1
- package/lib/tree/nodes/functions/log10Node.js +12 -1
- package/lib/tree/nodes/functions/logNode.d.ts +1 -0
- package/lib/tree/nodes/functions/logNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/logNode.js +12 -1
- package/package.json +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
|
|
4
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { round } from "../../../../math/utils/round.js";
|
|
7
|
+
import { exp } from "../../../../tree/nodes/functions/expNode.js";
|
|
8
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
9
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
10
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
11
|
+
const getPropositions = (n, { answer }) => {
|
|
12
|
+
const propositions = [];
|
|
13
|
+
addValidProp(propositions, answer);
|
|
14
|
+
propWhile(propositions, n, () => {
|
|
15
|
+
tryToAddWrongProp(propositions, randfloat(0.01, 0.9, 2).frenchify());
|
|
16
|
+
});
|
|
17
|
+
return shuffleProps(propositions, n);
|
|
18
|
+
};
|
|
19
|
+
const getAnswer = (identifiers) => {
|
|
20
|
+
const { k, lambda } = identifiers;
|
|
21
|
+
return round(substract(1, exp(-k * lambda)).evaluate(), 2).frenchify();
|
|
22
|
+
};
|
|
23
|
+
const getInstruction = (identifiers) => {
|
|
24
|
+
const { k, lambda } = identifiers;
|
|
25
|
+
return `Soit $X$ une variable aléatoire qui suit une loi exponentielle de paramètre $${lambda.frenchify()}$.
|
|
26
|
+
|
|
27
|
+
Calculer $P(X\\leq ${k})$.
|
|
28
|
+
|
|
29
|
+
Donner une valeur approchée au centième.`;
|
|
30
|
+
};
|
|
31
|
+
const getHint = () => {
|
|
32
|
+
return `Si $X$ suit une loi exponentielle de paramètre $\\lambda$, alors pour tout réel $t\\geq 0$, on a :
|
|
33
|
+
|
|
34
|
+
$$
|
|
35
|
+
P(X\\leq t) = 1-e^{-\\lambda t}
|
|
36
|
+
$$`;
|
|
37
|
+
};
|
|
38
|
+
const getCorrection = (identifiers) => {
|
|
39
|
+
const { k, lambda } = identifiers;
|
|
40
|
+
return `Si $X$ suit une loi exponentielle de paramètre $\\lambda$, alors pour tout réel $t\\geq 0$, on a :
|
|
41
|
+
|
|
42
|
+
$$
|
|
43
|
+
P(X\\leq t) = 1-e^{-\\lambda t}
|
|
44
|
+
$$
|
|
45
|
+
|
|
46
|
+
Ici, on a donc :
|
|
47
|
+
|
|
48
|
+
$$
|
|
49
|
+
P(X\\leq ${k}) = 1-e^{${multiply(-lambda, k).toTex()}} \\approx ${getAnswer(identifiers)}
|
|
50
|
+
$$`;
|
|
51
|
+
};
|
|
52
|
+
const getKeys = () => {
|
|
53
|
+
return [];
|
|
54
|
+
};
|
|
55
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
56
|
+
try {
|
|
57
|
+
return numberVEA(ans, answer);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
return handleVEAError(err);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const getExponentialLawComputeProbaQuestion = () => {
|
|
64
|
+
let lambda;
|
|
65
|
+
let k;
|
|
66
|
+
let rounded;
|
|
67
|
+
let counter = 0;
|
|
68
|
+
do {
|
|
69
|
+
counter++;
|
|
70
|
+
if (counter > 1000)
|
|
71
|
+
throw new Error("too many iterations in exponentialLawComputeProba");
|
|
72
|
+
lambda = randfloat(0.01, 1, 2);
|
|
73
|
+
k = randint(2, 20);
|
|
74
|
+
rounded = round(substract(1, exp(-k * lambda)).evaluate(), 2);
|
|
75
|
+
} while (rounded === 1);
|
|
76
|
+
const identifiers = {
|
|
77
|
+
lambda,
|
|
78
|
+
k,
|
|
79
|
+
};
|
|
80
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
81
|
+
};
|
|
82
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
83
|
+
return {
|
|
84
|
+
answer: getAnswer(identifiers),
|
|
85
|
+
instruction: getInstruction(identifiers),
|
|
86
|
+
keys: getKeys(identifiers),
|
|
87
|
+
answerFormat: "tex",
|
|
88
|
+
identifiers,
|
|
89
|
+
hint: getHint(identifiers),
|
|
90
|
+
correction: getCorrection(identifiers),
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
export const exponentialLawComputeProba = {
|
|
94
|
+
id: "exponentialLawComputeProba",
|
|
95
|
+
connector: "=",
|
|
96
|
+
label: "Calculer une probabilité du type $P(X\\leq t)$ pour une loi exponentielle",
|
|
97
|
+
isSingleStep: true,
|
|
98
|
+
generator: (nb, opts) => getDistinctQuestions(() => getExponentialLawComputeProbaQuestion(opts), nb),
|
|
99
|
+
qcmTimer: 60,
|
|
100
|
+
freeTimer: 60,
|
|
101
|
+
getPropositions,
|
|
102
|
+
isAnswerValid,
|
|
103
|
+
subject: "Mathématiques",
|
|
104
|
+
getInstruction,
|
|
105
|
+
getHint,
|
|
106
|
+
getCorrection,
|
|
107
|
+
getAnswer,
|
|
108
|
+
getQuestionFromIdentifiers,
|
|
109
|
+
hasHintAndCorrection: true,
|
|
110
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/exponential/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,yCAAyC,CAAC;AACxD,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
pIds: NodeIdentifiers;
|
|
5
|
+
};
|
|
6
|
+
export declare const geometricLawAverage: Exercise<Identifiers>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=geometricLawAverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometricLawAverage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/geometric/geometricLawAverage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAW7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AA8GF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAkBrD,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
|
|
4
|
+
import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
|
|
5
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
6
|
+
import { round } from "../../../../math/utils/round.js";
|
|
7
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
8
|
+
import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
9
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
10
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
11
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
12
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
13
|
+
import { approxOrEqual } from "../../../../utils/latex/approxOrEqual.js";
|
|
14
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
15
|
+
const { pIds } = identifiers;
|
|
16
|
+
const propositions = [];
|
|
17
|
+
addValidProp(propositions, answer);
|
|
18
|
+
const p = reifyAlgebraic(pIds);
|
|
19
|
+
tryToAddWrongProp(propositions, p.toTex());
|
|
20
|
+
propWhile(propositions, n, () => {
|
|
21
|
+
tryToAddWrongProp(propositions, coinFlip()
|
|
22
|
+
? RationalConstructor.randomIrreductibleProba().toTree().toTex()
|
|
23
|
+
: randfloat(0.1, 1, 2).frenchify());
|
|
24
|
+
});
|
|
25
|
+
return shuffleProps(propositions, n);
|
|
26
|
+
};
|
|
27
|
+
const getAnswer = (identifiers) => {
|
|
28
|
+
const { pIds } = identifiers;
|
|
29
|
+
const p = reifyAlgebraic(pIds);
|
|
30
|
+
if (isFractionNode(p)) {
|
|
31
|
+
return frac(1, p).simplify().toTex();
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return round(frac(1, p).evaluate(), 2).frenchify();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const getInstruction = (identifiers) => {
|
|
38
|
+
const { pIds } = identifiers;
|
|
39
|
+
const p = reifyAlgebraic(pIds);
|
|
40
|
+
return `Soit $X$ une variable aléatoire qui suit une loi géométrique de paramètre $${p.toTex()}$.
|
|
41
|
+
|
|
42
|
+
Quelle est l'espérance $E(X)$ de $X$ ? Donner la valeur exacte ou une valeur arrondie au centième.`;
|
|
43
|
+
};
|
|
44
|
+
const getHint = () => {
|
|
45
|
+
return `Si $X$ suit une loi géométrique de paramètre $p$, alors on a :
|
|
46
|
+
|
|
47
|
+
$$
|
|
48
|
+
E(X) = \\frac{1}{p}
|
|
49
|
+
$$`;
|
|
50
|
+
};
|
|
51
|
+
const getCorrection = (identifiers) => {
|
|
52
|
+
const { pIds } = identifiers;
|
|
53
|
+
const p = reifyAlgebraic(pIds);
|
|
54
|
+
const isFrac = isFractionNode(p);
|
|
55
|
+
const ratio = frac(1, p);
|
|
56
|
+
const ratioEv = ratio.evaluate();
|
|
57
|
+
const answer = getAnswer(identifiers);
|
|
58
|
+
return `Si $X$ suit une loi géométrique de paramètre $p$, alors on a :
|
|
59
|
+
|
|
60
|
+
$$
|
|
61
|
+
E(X) = \\frac{1}{p}
|
|
62
|
+
$$
|
|
63
|
+
|
|
64
|
+
Ici, on a donc :
|
|
65
|
+
|
|
66
|
+
${alignTex([
|
|
67
|
+
["E(X)", "=", ratio.toTex()],
|
|
68
|
+
isFrac ? ["", "=", answer] : ["", ...approxOrEqual(ratioEv, 2)],
|
|
69
|
+
])}
|
|
70
|
+
`;
|
|
71
|
+
};
|
|
72
|
+
const getKeys = () => {
|
|
73
|
+
return [];
|
|
74
|
+
};
|
|
75
|
+
const isAnswerValid = (ans, { answer: _answer, pIds }) => {
|
|
76
|
+
try {
|
|
77
|
+
const p = reifyAlgebraic(pIds);
|
|
78
|
+
const sol = frac(1, p).simplify();
|
|
79
|
+
const solEv = round(sol.evaluate(), 2);
|
|
80
|
+
return (parseAlgebraic(ans).simplify().toTex() === sol.toTex() ||
|
|
81
|
+
numberVEA(ans, solEv.frenchify(), 2));
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
return handleVEAError(err);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const getGeometricLawAverageQuestion = () => {
|
|
88
|
+
const p = coinFlip()
|
|
89
|
+
? RationalConstructor.randomIrreductibleProba().toTree()
|
|
90
|
+
: randfloat(0.1, 1, 2).toTree();
|
|
91
|
+
const identifiers = {
|
|
92
|
+
pIds: p.toIdentifiers(),
|
|
93
|
+
};
|
|
94
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
95
|
+
};
|
|
96
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
97
|
+
return {
|
|
98
|
+
answer: getAnswer(identifiers),
|
|
99
|
+
instruction: getInstruction(identifiers),
|
|
100
|
+
keys: getKeys(identifiers),
|
|
101
|
+
answerFormat: "tex",
|
|
102
|
+
identifiers,
|
|
103
|
+
hint: getHint(identifiers),
|
|
104
|
+
correction: getCorrection(identifiers),
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
export const geometricLawAverage = {
|
|
108
|
+
id: "geometricLawAverage",
|
|
109
|
+
connector: "=",
|
|
110
|
+
label: "Déterminer l'espérane d'une loi géométrique",
|
|
111
|
+
isSingleStep: true,
|
|
112
|
+
generator: (nb, opts) => getDistinctQuestions(() => getGeometricLawAverageQuestion(opts), nb),
|
|
113
|
+
qcmTimer: 60,
|
|
114
|
+
freeTimer: 60,
|
|
115
|
+
getPropositions,
|
|
116
|
+
isAnswerValid,
|
|
117
|
+
subject: "Mathématiques",
|
|
118
|
+
getInstruction,
|
|
119
|
+
getHint,
|
|
120
|
+
getCorrection,
|
|
121
|
+
getAnswer,
|
|
122
|
+
getQuestionFromIdentifiers,
|
|
123
|
+
hasHintAndCorrection: true,
|
|
124
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
pIds: NodeIdentifiers;
|
|
5
|
+
k: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const geometricLawComputeProba: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=geometricLawComputeProba.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometricLawComputeProba.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/geometric/geometricLawComputeProba.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,eAAe,CAAC;IACtB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAwGF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAmB1D,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
|
|
4
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { round } from "../../../../math/utils/round.js";
|
|
7
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
8
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
9
|
+
import { power } from "../../../../tree/nodes/operators/powerNode.js";
|
|
10
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
11
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
12
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
13
|
+
import { approxOrEqual } from "../../../../utils/latex/approxOrEqual.js";
|
|
14
|
+
const getPropositions = (n, { answer }) => {
|
|
15
|
+
const propositions = [];
|
|
16
|
+
addValidProp(propositions, answer);
|
|
17
|
+
propWhile(propositions, n, () => {
|
|
18
|
+
tryToAddWrongProp(propositions, randfloat(0.1, 0.9, 3).frenchify());
|
|
19
|
+
});
|
|
20
|
+
return shuffleProps(propositions, n);
|
|
21
|
+
};
|
|
22
|
+
const getAnswer = (identifiers) => {
|
|
23
|
+
const { pIds, k } = identifiers;
|
|
24
|
+
const p = reifyAlgebraic(pIds);
|
|
25
|
+
const proba = multiply(p, power(substract(1, p), substract(k, 1)));
|
|
26
|
+
return round(proba.evaluate(), 3).frenchify();
|
|
27
|
+
};
|
|
28
|
+
const getInstruction = (identifiers) => {
|
|
29
|
+
const { pIds, k } = identifiers;
|
|
30
|
+
const p = reifyAlgebraic(pIds);
|
|
31
|
+
return `Soit $X$ une variable aléatoire qui suit une loi géométrique de paramètre $${p.toTex()}$.
|
|
32
|
+
|
|
33
|
+
Calculer $P(X=${k})$.
|
|
34
|
+
|
|
35
|
+
Donner une valeur arrondie au millième.`;
|
|
36
|
+
};
|
|
37
|
+
const getHint = () => {
|
|
38
|
+
return `Si $X$ suit une loi géométrique de paramètre $p$, alors pour tout entier naturel $k$ non nul, on a :
|
|
39
|
+
|
|
40
|
+
$$
|
|
41
|
+
P(X=k) = p\\times (1-p)^{k-1}
|
|
42
|
+
$$`;
|
|
43
|
+
};
|
|
44
|
+
const getCorrection = (identifiers) => {
|
|
45
|
+
const { pIds, k } = identifiers;
|
|
46
|
+
const p = reifyAlgebraic(pIds);
|
|
47
|
+
const proba = multiply(p, power(substract(1, p), substract(k, 1)));
|
|
48
|
+
return `Si $X$ suit une loi géométrique de paramètre $p$, alors pour tout entier naturel $k$ non nul, on a :
|
|
49
|
+
|
|
50
|
+
$$
|
|
51
|
+
P(X=k) = p\\times (1-p)^{k-1}
|
|
52
|
+
$$
|
|
53
|
+
|
|
54
|
+
Ici, on a donc :
|
|
55
|
+
|
|
56
|
+
${alignTex([
|
|
57
|
+
[`P(X=${k})`, "=", proba.toTex()],
|
|
58
|
+
["", ...approxOrEqual(proba.evaluate(), 3)],
|
|
59
|
+
])}
|
|
60
|
+
`;
|
|
61
|
+
};
|
|
62
|
+
const getKeys = () => {
|
|
63
|
+
return [];
|
|
64
|
+
};
|
|
65
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
66
|
+
try {
|
|
67
|
+
return numberVEA(ans, answer);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
return handleVEAError(err);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const getGeometricLawComputeProbaQuestion = () => {
|
|
74
|
+
let p;
|
|
75
|
+
let k;
|
|
76
|
+
let rounded = 0;
|
|
77
|
+
let counter = 0;
|
|
78
|
+
do {
|
|
79
|
+
counter++;
|
|
80
|
+
if (counter > 1000)
|
|
81
|
+
throw new Error("too many iterations in geometricLawComputeProba");
|
|
82
|
+
p = randfloat(0.1, 1, 1);
|
|
83
|
+
k = randint(2, 10);
|
|
84
|
+
const proba = multiply(p, power(substract(1, p), substract(k, 1)));
|
|
85
|
+
rounded = round(proba.evaluate(), 3);
|
|
86
|
+
} while (rounded < 0.002);
|
|
87
|
+
const identifiers = {
|
|
88
|
+
k,
|
|
89
|
+
pIds: p.toTree().toIdentifiers(),
|
|
90
|
+
};
|
|
91
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
92
|
+
};
|
|
93
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
94
|
+
return {
|
|
95
|
+
answer: getAnswer(identifiers),
|
|
96
|
+
instruction: getInstruction(identifiers),
|
|
97
|
+
keys: getKeys(identifiers),
|
|
98
|
+
answerFormat: "tex",
|
|
99
|
+
identifiers,
|
|
100
|
+
hint: getHint(identifiers),
|
|
101
|
+
correction: getCorrection(identifiers),
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export const geometricLawComputeProba = {
|
|
105
|
+
id: "geometricLawComputeProba",
|
|
106
|
+
connector: "=",
|
|
107
|
+
label: "Calculer une probabilté $P(X=k)$ pour une variable aléatoire suivant une loi géométrique",
|
|
108
|
+
isSingleStep: true,
|
|
109
|
+
generator: (nb, opts) => getDistinctQuestions(() => getGeometricLawComputeProbaQuestion(opts), nb),
|
|
110
|
+
qcmTimer: 60,
|
|
111
|
+
freeTimer: 60,
|
|
112
|
+
getPropositions,
|
|
113
|
+
isAnswerValid,
|
|
114
|
+
subject: "Mathématiques",
|
|
115
|
+
getInstruction,
|
|
116
|
+
getHint,
|
|
117
|
+
getCorrection,
|
|
118
|
+
getAnswer,
|
|
119
|
+
getQuestionFromIdentifiers,
|
|
120
|
+
hasHintAndCorrection: true,
|
|
121
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/geometric/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC"}
|
|
@@ -16,4 +16,8 @@ export * from "./conditional/index.js";
|
|
|
16
16
|
export * from "./twoStepExperiments/index.js";
|
|
17
17
|
export * from "./trees/index.js";
|
|
18
18
|
export * from "./tchebychev/index.js";
|
|
19
|
+
export * from "./geometric/index.js";
|
|
20
|
+
export * from "./density/index.js";
|
|
21
|
+
export * from "./uniform/index.js";
|
|
22
|
+
export * from "./exponential/index.js";
|
|
19
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
|
|
@@ -16,3 +16,7 @@ export * from "./conditional/index.js";
|
|
|
16
16
|
export * from "./twoStepExperiments/index.js";
|
|
17
17
|
export * from "./trees/index.js";
|
|
18
18
|
export * from "./tchebychev/index.js";
|
|
19
|
+
export * from "./geometric/index.js";
|
|
20
|
+
export * from "./density/index.js";
|
|
21
|
+
export * from "./uniform/index.js";
|
|
22
|
+
export * from "./exponential/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fineAdjustementExercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats2var/fineAdjustementExercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"fineAdjustementExercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats2var/fineAdjustementExercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAGL,sBAAsB,EACvB,MAAM,oCAAoC,CAAC;AAM5C,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,sBAAsB,EAAE,sBAAsB,CAAC;CAChD,CAAC;AA0JF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAczD,CAAC"}
|
|
@@ -46,6 +46,18 @@ const getGGBOptions = (identifiers) => {
|
|
|
46
46
|
coords: ggb.getAdaptedCoords({ xMin, xMax, yMin, yMax }),
|
|
47
47
|
});
|
|
48
48
|
};
|
|
49
|
+
const getHint = () => {
|
|
50
|
+
return `Le coefficient de détermination indique si un ajustement affine est pertinent ou non pour la série statistique considérée. Plus il est proche de $1$, plus l'ajustement affine est pertinent. Plus il est proche de $0$, moins l'ajustement affine est pertinent.`;
|
|
51
|
+
};
|
|
52
|
+
const getCorrection = (identifiers) => {
|
|
53
|
+
const { isJustified, cloudPointsIdentifiers } = identifiers;
|
|
54
|
+
const cloudPoints = new CloudPoints(cloudPointsIdentifiers.pointsIdentifiers.map((i) => PointConstructor.fromIdentifiers(i)));
|
|
55
|
+
const coeff = cloudPoints.getCorrelationCoeff().value;
|
|
56
|
+
const determinationCoeff = new NumberNode(+(coeff * coeff).toFixed(2));
|
|
57
|
+
return isJustified
|
|
58
|
+
? `Les points du nuage de points représentant cette série statistique sont "presque" alignés. Il semblerait pertinent donc d'ajuster cette série statistique par un ajustement affine. Le coefficient de détermination doit donc être proche de $1$ pour cette série statistique. Parmi les choix proposés, on en déduit donc que ce coefficient vaut $${determinationCoeff.toTex()}$. `
|
|
59
|
+
: `Ici, les points du nuage de points ne semblent pas du tout former une droite : il ne semble donc pas pertinent d'ajuster cette série statistique par un ajustement affine. Le coefficient de détermination doit donc être proche de $0$ pour cette série statistique. Parmi les choix proposés, on en conclut que ce coefficient vaut $${determinationCoeff.toTex()}$. `;
|
|
60
|
+
};
|
|
49
61
|
const getFineAdjustementExerciseQuestion = () => {
|
|
50
62
|
const flip = coinFlip();
|
|
51
63
|
const cloudPoints = flip
|
|
@@ -73,6 +85,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
|
|
|
73
85
|
keys: [],
|
|
74
86
|
answerFormat: "raw",
|
|
75
87
|
identifiers,
|
|
88
|
+
hint: getHint(identifiers),
|
|
89
|
+
correction: getCorrection(identifiers),
|
|
76
90
|
};
|
|
77
91
|
return question;
|
|
78
92
|
};
|
|
@@ -111,4 +125,5 @@ export const fineAdjustementExercise = {
|
|
|
111
125
|
getPropositions,
|
|
112
126
|
subject: "Mathématiques",
|
|
113
127
|
getQuestionFromIdentifiers,
|
|
128
|
+
hasHintAndCorrection: true,
|
|
114
129
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/uniform/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniformAverage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/uniform/uniformAverage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA2FF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAkBhD,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
6
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
7
|
+
const getPropositions = (n, { answer }) => {
|
|
8
|
+
const propositions = [];
|
|
9
|
+
addValidProp(propositions, answer);
|
|
10
|
+
propWhile(propositions, n, () => {
|
|
11
|
+
const a = randint(-10, 20);
|
|
12
|
+
const b = randint(a + 1, a + 20);
|
|
13
|
+
tryToAddWrongProp(propositions, frac(a + b, 2)
|
|
14
|
+
.simplify()
|
|
15
|
+
.toTex());
|
|
16
|
+
});
|
|
17
|
+
return shuffleProps(propositions, n);
|
|
18
|
+
};
|
|
19
|
+
const getAnswer = (identifiers) => {
|
|
20
|
+
const { a, b } = identifiers;
|
|
21
|
+
return frac(a + b, 2)
|
|
22
|
+
.simplify()
|
|
23
|
+
.toTex();
|
|
24
|
+
};
|
|
25
|
+
const getInstruction = (identifiers) => {
|
|
26
|
+
const { a, b } = identifiers;
|
|
27
|
+
return `Soit $X$ une variable aléatoire qui suit une loi uniforme sur $[${a};${b}]$.
|
|
28
|
+
|
|
29
|
+
Calculer l'espérance $E(X)$ de $X$.`;
|
|
30
|
+
};
|
|
31
|
+
const getHint = () => {
|
|
32
|
+
return `Si $X$ suit une loi uniforme sur $[a;b]$, alors son espérance vaut :
|
|
33
|
+
|
|
34
|
+
$$
|
|
35
|
+
E(X) = \\frac{a+b}{2}
|
|
36
|
+
$$`;
|
|
37
|
+
};
|
|
38
|
+
const getCorrection = (identifiers) => {
|
|
39
|
+
const { a, b } = identifiers;
|
|
40
|
+
return `Si $X$ suit une loi uniforme sur $[a;b]$, alors son espérance vaut :
|
|
41
|
+
|
|
42
|
+
$$
|
|
43
|
+
E(X) = \\frac{a+b}{2}
|
|
44
|
+
$$
|
|
45
|
+
|
|
46
|
+
Ici, on a donc :
|
|
47
|
+
|
|
48
|
+
$$
|
|
49
|
+
E(X) = ${frac(a + b, 2).toSimplificationTex()}
|
|
50
|
+
$$`;
|
|
51
|
+
};
|
|
52
|
+
const getKeys = () => {
|
|
53
|
+
return [];
|
|
54
|
+
};
|
|
55
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
56
|
+
try {
|
|
57
|
+
return rationalVEA(ans, answer);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
return handleVEAError(err);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const getUniformAverageQuestion = () => {
|
|
64
|
+
const a = randint(-10, 20);
|
|
65
|
+
const b = randint(a + 1, a + 20);
|
|
66
|
+
const identifiers = {
|
|
67
|
+
a,
|
|
68
|
+
b,
|
|
69
|
+
};
|
|
70
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
71
|
+
};
|
|
72
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
73
|
+
return {
|
|
74
|
+
answer: getAnswer(identifiers),
|
|
75
|
+
instruction: getInstruction(identifiers),
|
|
76
|
+
keys: getKeys(identifiers),
|
|
77
|
+
answerFormat: "tex",
|
|
78
|
+
identifiers,
|
|
79
|
+
hint: getHint(identifiers),
|
|
80
|
+
correction: getCorrection(identifiers),
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export const uniformAverage = {
|
|
84
|
+
id: "uniformAverage",
|
|
85
|
+
connector: "=",
|
|
86
|
+
label: "Calculer l'espérance d'une loi uniforme",
|
|
87
|
+
isSingleStep: true,
|
|
88
|
+
generator: (nb, opts) => getDistinctQuestions(() => getUniformAverageQuestion(opts), nb),
|
|
89
|
+
qcmTimer: 60,
|
|
90
|
+
freeTimer: 60,
|
|
91
|
+
getPropositions,
|
|
92
|
+
isAnswerValid,
|
|
93
|
+
subject: "Mathématiques",
|
|
94
|
+
getInstruction,
|
|
95
|
+
getHint,
|
|
96
|
+
getCorrection,
|
|
97
|
+
getAnswer,
|
|
98
|
+
getQuestionFromIdentifiers,
|
|
99
|
+
hasHintAndCorrection: true,
|
|
100
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
a: number;
|
|
4
|
+
b: number;
|
|
5
|
+
c: number;
|
|
6
|
+
d: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const uniformLawComputeProba: Exercise<Identifiers>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=uniformLawComputeProba.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniformLawComputeProba.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/uniform/uniformLawComputeProba.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CAEX,CAAC;AAgGF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAmBxD,CAAC"}
|