math-exercises 3.0.170 → 3.0.172
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/derivation/variations/signVarTable3dDegree.js +38 -10
- package/lib/exercises/math/derivation/variations/signVarTableFromDerivativeGraph.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableFromDerivativeGraph.js +7 -4
- package/lib/exercises/math/derivation/variations/signVarTableFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableFromGraph.js +2 -3
- package/lib/exercises/math/functions/trinoms/problems/index.d.ts +1 -0
- package/lib/exercises/math/functions/trinoms/problems/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/problems/index.js +1 -0
- package/lib/exercises/math/functions/trinoms/problems/rectangleSizesFromPerimeterAndArea.d.ts +9 -0
- package/lib/exercises/math/functions/trinoms/problems/rectangleSizesFromPerimeterAndArea.d.ts.map +1 -0
- package/lib/exercises/math/functions/trinoms/problems/rectangleSizesFromPerimeterAndArea.js +202 -0
- package/lib/exercises/math/functions/variations/partialVarTableFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/functions/variations/partialVarTableFromGraph.js +2 -1
- package/lib/exercises/math/functions/variations/varTableFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/functions/variations/varTableFromGraph.js +2 -1
- package/lib/exercises/math/functions/variations/varTableFromSentences.d.ts.map +1 -1
- package/lib/exercises/math/functions/variations/varTableFromSentences.js +2 -1
- package/lib/exercises/math/geometry/circles/circleCenterAndRadiusFromEquation.d.ts.map +1 -1
- package/lib/exercises/math/geometry/circles/circleCenterAndRadiusFromEquation.js +0 -2
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiAngle.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiAngle.js +64 -60
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.d.ts +1 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.js +173 -47
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiSideLength.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiSideLength.js +112 -46
- package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductIdentities.js +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductInOrthonormalBasisIJ.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductInOrthonormalBasisIJ.js +6 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductLamdbaULambdaV.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductLamdbaULambdaV.js +60 -82
- package/lib/exercises/math/geometry/vectors/scalarProduct/angleFromScalarProduct.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/angleFromScalarProduct.js +92 -6
- package/lib/exercises/math/geometry/vectors/scalarProduct/index.d.ts +6 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/index.js +6 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsOrthogonalVecsBasisIJ.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsOrthogonalVecsBasisIJ.js +6 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsOrthogonalVecsUsingCoords.js +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnCircle.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnCircle.js +15 -5
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnPerpendicularBisector.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnPerpendicularBisector.js +18 -14
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsRightTriangleUsingPointCoords.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsRightTriangleUsingPointCoords.js +15 -5
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.js +38 -4
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOfVectsOnGrid1.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOfVectsOnGrid1.js +77 -26
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductParallelogramDiagonalPlus.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductParallelogramDiagonalPlus.js +6 -7
- package/lib/exercises/math/probaStat/basicProbas/calculateProbaFromProbaLaw.js +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +3 -16
- package/lib/exercises/math/probaStat/randomVariable/calculateProbaFromVATableLaw.d.ts +11 -0
- package/lib/exercises/math/probaStat/randomVariable/calculateProbaFromVATableLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/calculateProbaFromVATableLaw.js +232 -0
- package/lib/exercises/math/probaStat/randomVariable/decideWhichGameIsLessRisky.d.ts +14 -0
- package/lib/exercises/math/probaStat/randomVariable/decideWhichGameIsLessRisky.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/decideWhichGameIsLessRisky.js +167 -0
- package/lib/exercises/math/probaStat/randomVariable/findValueForFairRandomVariable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/findValueForFairRandomVariable.js +29 -56
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/index.js +9 -0
- package/lib/exercises/math/probaStat/randomVariable/isTableProbabilityLaw.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/isTableProbabilityLaw.js +6 -6
- package/lib/exercises/math/probaStat/randomVariable/randomVariableAverage.js +1 -1
- package/lib/exercises/math/probaStat/randomVariable/randomVariableFindMissingProbabilityInLaw.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableFindMissingProbabilityInLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableFindMissingProbabilityInLaw.js +116 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationAverage.d.ts +11 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationAverage.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationAverage.js +112 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationComputeProbability.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationComputeProbability.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationComputeProbability.js +176 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationIsGameFavorable.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationIsGameFavorable.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationIsGameFavorable.js +94 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.js +162 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationStandardDeviation.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationStandardDeviation.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationStandardDeviation.js +133 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationValues.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationValues.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationValues.js +211 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationVariance.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationVariance.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationVariance.js +113 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableStandardDeviation.js +1 -1
- package/lib/exercises/math/probaStat/randomVariable/randomVariableVariance.js +1 -1
- package/lib/exercises/math/probaStat/randomVariable/utils/buildVAOfGivenAverage.d.ts +31 -0
- package/lib/exercises/math/probaStat/randomVariable/utils/buildVAOfGivenAverage.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/utils/buildVAOfGivenAverage.js +192 -0
- package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.d.ts +40 -11
- package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.js +172 -30
- package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/medianWithList.js +16 -2
- package/lib/exercises/math/sequences/arithmetic/arithmeticVariations.js +1 -1
- package/lib/exercises/math/trigonometry/circle/placeAssociateAngleOnCircle.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/circle/placeAssociateAngleOnCircle.js +0 -2
- package/lib/exercises/vea/rationalVEA.d.ts.map +1 -1
- package/lib/exercises/vea/rationalVEA.js +7 -3
- package/lib/exercises/vea/varLineVEA.d.ts.map +1 -1
- package/lib/exercises/vea/varLineVEA.js +2 -1
- package/lib/exercises/vea/varSignTableVEA.d.ts +8 -0
- package/lib/exercises/vea/varSignTableVEA.d.ts.map +1 -1
- package/lib/exercises/vea/varSignTableVEA.js +8 -0
- package/lib/exercises/vea/xTableLineVEA.d.ts +1 -0
- package/lib/exercises/vea/xTableLineVEA.d.ts.map +1 -1
- package/lib/exercises/vea/xTableLineVEA.js +1 -0
- package/lib/index.d.ts +86 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/latexTester.d.ts.map +1 -1
- package/lib/latexTester.js +3 -1
- package/lib/math/geometry/angle.d.ts +2 -0
- package/lib/math/geometry/angle.d.ts.map +1 -1
- package/lib/math/geometry/angle.js +17 -0
- package/lib/math/geometry/point.js +2 -2
- package/lib/math/geometry/segment.js +1 -1
- package/lib/math/numbers/reals/real.d.ts.map +1 -1
- package/lib/math/numbers/reals/real.js +4 -0
- package/lib/math/probability/randomVariable.d.ts +2 -1
- package/lib/math/probability/randomVariable.d.ts.map +1 -1
- package/lib/math/probability/randomVariable.js +7 -1
- package/lib/math/utils/arithmetic/primeFactors.d.ts +1 -1
- package/lib/math/utils/arithmetic/primeFactors.d.ts.map +1 -1
- package/lib/math/utils/arithmetic/primeFactors.js +23 -9
- package/lib/math/utils/random/randTupleInt.d.ts +1 -0
- package/lib/math/utils/random/randTupleInt.d.ts.map +1 -1
- package/lib/math/utils/random/randTupleInt.js +3 -0
- package/lib/tests/exosTest.d.ts.map +1 -1
- package/lib/tests/exosTest.js +2 -0
- package/lib/tests/pdfs/mdTableToLatexTabular.js +1 -1
- package/lib/tree/nodes/algebraicNode.d.ts +1 -0
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/complex/complexNode.d.ts +1 -0
- package/lib/tree/nodes/complex/complexNode.d.ts.map +1 -1
- package/lib/tree/nodes/complex/complexNode.js +3 -0
- package/lib/tree/nodes/equations/equalNode.d.ts +1 -0
- package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equalNode.js +3 -0
- package/lib/tree/nodes/equations/equationSolutionNode.d.ts +1 -0
- package/lib/tree/nodes/equations/equationSolutionNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equationSolutionNode.js +3 -0
- package/lib/tree/nodes/equations/multiEqualNode.d.ts +1 -0
- package/lib/tree/nodes/equations/multiEqualNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/multiEqualNode.js +3 -0
- package/lib/tree/nodes/equations/notEqualNode.d.ts +1 -0
- package/lib/tree/nodes/equations/notEqualNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/notEqualNode.js +3 -0
- package/lib/tree/nodes/functions/absNode.d.ts +1 -0
- package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/absNode.js +7 -0
- package/lib/tree/nodes/functions/arcSinNode.d.ts +1 -0
- package/lib/tree/nodes/functions/arcSinNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/arcSinNode.js +7 -0
- package/lib/tree/nodes/functions/arccosNode.d.ts +1 -0
- package/lib/tree/nodes/functions/arccosNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/arccosNode.js +7 -0
- package/lib/tree/nodes/functions/arctanNode.d.ts +1 -0
- package/lib/tree/nodes/functions/arctanNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/arctanNode.js +7 -0
- package/lib/tree/nodes/functions/cosNode.d.ts +1 -0
- package/lib/tree/nodes/functions/cosNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/cosNode.js +7 -0
- package/lib/tree/nodes/functions/expNode.d.ts +1 -0
- package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/expNode.js +7 -0
- package/lib/tree/nodes/functions/factorialNode.d.ts +30 -0
- package/lib/tree/nodes/functions/factorialNode.d.ts.map +1 -0
- package/lib/tree/nodes/functions/factorialNode.js +79 -0
- package/lib/tree/nodes/functions/functionNode.d.ts +2 -1
- package/lib/tree/nodes/functions/functionNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/functionNode.js +1 -0
- package/lib/tree/nodes/functions/integralNode.d.ts +1 -0
- package/lib/tree/nodes/functions/integralNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/integralNode.js +7 -0
- 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 +7 -0
- 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 +9 -0
- package/lib/tree/nodes/functions/oppositeNode.d.ts +1 -0
- package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.js +7 -0
- package/lib/tree/nodes/functions/sinNode.d.ts +1 -0
- package/lib/tree/nodes/functions/sinNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sinNode.js +7 -0
- package/lib/tree/nodes/functions/sqrtNode.d.ts +1 -0
- package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.js +7 -0
- package/lib/tree/nodes/functions/tanNode.d.ts +1 -0
- package/lib/tree/nodes/functions/tanNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/tanNode.js +7 -0
- package/lib/tree/nodes/geometry/degree.d.ts +1 -0
- package/lib/tree/nodes/geometry/degree.d.ts.map +1 -1
- package/lib/tree/nodes/geometry/degree.js +7 -0
- package/lib/tree/nodes/geometry/lengthNode.d.ts +1 -0
- package/lib/tree/nodes/geometry/lengthNode.d.ts.map +1 -1
- package/lib/tree/nodes/geometry/lengthNode.js +7 -0
- package/lib/tree/nodes/geometry/pointNode.d.ts +1 -0
- package/lib/tree/nodes/geometry/pointNode.d.ts.map +1 -1
- package/lib/tree/nodes/geometry/pointNode.js +7 -0
- package/lib/tree/nodes/geometry/vectorNode.d.ts +1 -0
- package/lib/tree/nodes/geometry/vectorNode.d.ts.map +1 -1
- package/lib/tree/nodes/geometry/vectorNode.js +7 -0
- package/lib/tree/nodes/inequations/inequationNode.d.ts +1 -0
- package/lib/tree/nodes/inequations/inequationNode.d.ts.map +1 -1
- package/lib/tree/nodes/inequations/inequationNode.js +7 -0
- package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts +1 -0
- package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts.map +1 -1
- package/lib/tree/nodes/inequations/inequationSolutionNode.js +7 -0
- 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 +2 -0
- package/lib/tree/nodes/nodeConstructor.d.ts.map +1 -1
- package/lib/tree/nodes/nodeConstructor.js +4 -0
- package/lib/tree/nodes/numbers/percentNode.d.ts +1 -0
- package/lib/tree/nodes/numbers/percentNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/percentNode.js +7 -0
- package/lib/tree/nodes/operators/addNode.d.ts +1 -0
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +7 -0
- package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts +2 -1
- package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/binomialCoefficientNode.js +18 -2
- package/lib/tree/nodes/operators/divideNode.d.ts +1 -0
- package/lib/tree/nodes/operators/divideNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/divideNode.js +7 -0
- package/lib/tree/nodes/operators/fractionNode.d.ts +1 -0
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +7 -0
- package/lib/tree/nodes/operators/limitNode.d.ts +1 -0
- package/lib/tree/nodes/operators/limitNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/limitNode.js +7 -0
- package/lib/tree/nodes/operators/multiplyNode.d.ts +1 -0
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +7 -0
- package/lib/tree/nodes/operators/powerNode.d.ts +1 -0
- package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/powerNode.js +7 -0
- package/lib/tree/nodes/operators/substractNode.d.ts +1 -0
- package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.js +7 -0
- package/lib/tree/nodes/polynomials/monomNode.d.ts +1 -0
- package/lib/tree/nodes/polynomials/monomNode.d.ts.map +1 -1
- package/lib/tree/nodes/polynomials/monomNode.js +7 -0
- package/lib/tree/nodes/polynomials/trinomNode.d.ts +1 -0
- package/lib/tree/nodes/polynomials/trinomNode.d.ts.map +1 -1
- package/lib/tree/nodes/polynomials/trinomNode.js +7 -0
- package/lib/tree/nodes/sets/belongsNode.d.ts +1 -0
- package/lib/tree/nodes/sets/belongsNode.d.ts.map +1 -1
- package/lib/tree/nodes/sets/belongsNode.js +7 -0
- package/lib/tree/nodes/sets/discreteSetNode.d.ts +1 -0
- package/lib/tree/nodes/sets/discreteSetNode.d.ts.map +1 -1
- package/lib/tree/nodes/sets/discreteSetNode.js +7 -0
- package/lib/tree/nodes/sets/intervalNode.d.ts +1 -0
- package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
- package/lib/tree/nodes/sets/intervalNode.js +7 -0
- package/lib/tree/nodes/sets/unionIntervalNode.d.ts +1 -0
- package/lib/tree/nodes/sets/unionIntervalNode.d.ts.map +1 -1
- package/lib/tree/nodes/sets/unionIntervalNode.js +7 -0
- package/lib/tree/nodes/variables/variableNode.d.ts +1 -0
- package/lib/tree/nodes/variables/variableNode.d.ts.map +1 -1
- package/lib/tree/nodes/variables/variableNode.js +7 -0
- package/lib/tree/utilities/nodeShuffler.d.ts.map +1 -1
- package/lib/tree/utilities/nodeShuffler.js +3 -0
- package/lib/tree/utilities/nodeSimplifier.d.ts.map +1 -1
- package/lib/tree/utilities/nodeSimplifier.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
|
|
4
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
5
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
6
|
+
import { DiscreteSetNode } from "../../../../tree/nodes/sets/discreteSetNode.js";
|
|
7
|
+
import { discreteSetParser } from "../../../../tree/parsers/discreteSetParser.js";
|
|
8
|
+
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
9
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
10
|
+
import { buildRandomVariableSituation, getRandomVariableSituation, } from "./utils/randomVariableSituations.js";
|
|
11
|
+
const getAnswer = (identifiers) => {
|
|
12
|
+
const { params } = identifiers;
|
|
13
|
+
const va = getRandomVariableSituation(params).getVA();
|
|
14
|
+
return new DiscreteSetNode(va.xValues).simplify().toTex();
|
|
15
|
+
};
|
|
16
|
+
const getPropositions = (_n, { answer, params }) => {
|
|
17
|
+
const propositions = [];
|
|
18
|
+
addValidProp(propositions, answer);
|
|
19
|
+
switch (params.id) {
|
|
20
|
+
case "coin":
|
|
21
|
+
tryToAddWrongProp(propositions, new DiscreteSetNode([params.a.toTree(), params.b.toTree()])
|
|
22
|
+
.simplify()
|
|
23
|
+
.toTex());
|
|
24
|
+
tryToAddWrongProp(propositions, new DiscreteSetNode(["\\text{Pile}".toTree(), "\\text{Face}".toTree()])
|
|
25
|
+
.simplify()
|
|
26
|
+
.toTex());
|
|
27
|
+
tryToAddWrongProp(propositions, new DiscreteSetNode([params.a.toTree(), (-params.b).toTree()])
|
|
28
|
+
.simplify()
|
|
29
|
+
.toTex());
|
|
30
|
+
tryToAddWrongProp(propositions, new DiscreteSetNode([params.a.toTree(), params.b.toTree()])
|
|
31
|
+
.simplify()
|
|
32
|
+
.toTex());
|
|
33
|
+
break;
|
|
34
|
+
case "urne":
|
|
35
|
+
tryToAddWrongProp(propositions, new DiscreteSetNode([
|
|
36
|
+
"\\text{Blanche}".toTree(),
|
|
37
|
+
"\\text{Rouge}".toTree(),
|
|
38
|
+
"\\text{Noire}".toTree(),
|
|
39
|
+
])
|
|
40
|
+
.simplify()
|
|
41
|
+
.toTex());
|
|
42
|
+
tryToAddWrongProp(propositions, new DiscreteSetNode([
|
|
43
|
+
params.b.toTree(),
|
|
44
|
+
params.r.toTree(),
|
|
45
|
+
params.n.toTree(),
|
|
46
|
+
])
|
|
47
|
+
.simplify()
|
|
48
|
+
.toTex());
|
|
49
|
+
tryToAddWrongProp(propositions, new DiscreteSetNode([
|
|
50
|
+
params.gb.toTree(),
|
|
51
|
+
params.gr.toTree(),
|
|
52
|
+
(-params.gn).toTree(),
|
|
53
|
+
])
|
|
54
|
+
.simplify()
|
|
55
|
+
.toTex());
|
|
56
|
+
break;
|
|
57
|
+
case "diceMultiple": {
|
|
58
|
+
const allValues = [...Array(params.n).keys()].map((i) => i + 1);
|
|
59
|
+
const multiples = [];
|
|
60
|
+
for (let i = 1; i < params.n; i++) {
|
|
61
|
+
if (i % params.winningMultiple === 0) {
|
|
62
|
+
multiples.push(i);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
tryToAddWrongProp(propositions, new DiscreteSetNode(multiples.map((m) => m.toTree()))
|
|
66
|
+
.simplify()
|
|
67
|
+
.toTex());
|
|
68
|
+
tryToAddWrongProp(propositions, new DiscreteSetNode(allValues.map((v) => v.toTree()))
|
|
69
|
+
.simplify()
|
|
70
|
+
.toTex());
|
|
71
|
+
tryToAddWrongProp(propositions, new DiscreteSetNode([params.gain.toTree(), params.loss.toTree()])
|
|
72
|
+
.simplify()
|
|
73
|
+
.toTex());
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return shuffle(propositions);
|
|
77
|
+
};
|
|
78
|
+
const getInstruction = (identifiers) => {
|
|
79
|
+
const { params } = identifiers;
|
|
80
|
+
const context = getRandomVariableSituation(params).getContext();
|
|
81
|
+
return (context +
|
|
82
|
+
`
|
|
83
|
+
|
|
84
|
+
Quel est l'ensemble des valeurs possibles pour $X$ ?`);
|
|
85
|
+
};
|
|
86
|
+
const getHint = (identifiers) => {
|
|
87
|
+
const { params } = identifiers;
|
|
88
|
+
switch (params.id) {
|
|
89
|
+
case "coin":
|
|
90
|
+
return `La variable aléatoire $X$ donne le gain algébrique du joueur (c'est à dire un gain qui peut être négatif si le joueur perd des points) en fonction du résultat de ses lancers. Les valeurs $x_i$ qu'elle prend sont donc les valeurs de gain (ou de perte) possibles.`;
|
|
91
|
+
case "urne":
|
|
92
|
+
return `La variable aléatoire $X$ donne le gain algébrique du joueur (c'est à dire un gain qui peut être négatif si le joueur perd de l'argent) en fonction de la boule qu'il a tirée. Les valeurs $x_i$ qu'elle prend sont donc les valeurs de gain (ou de perte) possibles.`;
|
|
93
|
+
case "diceMultiple":
|
|
94
|
+
return `La variable aléatoire $X$ donne le gain algébrique du joueur (c'est à dire un gain qui peut être négatif si le joueur perd de l'argent) en fonction de la face obtenue. Les valeurs $x_i$ qu'elle prend sont donc les valeurs de gain (ou de perte) possibles.`;
|
|
95
|
+
case "cards":
|
|
96
|
+
return `La variable aléatoire $X$ donne le gain algébrique du joueur (c'est à dire un gain qui peut être négatif si le joueur perd de l'argent) en fonction de la carte qu'il a tirée. Les valeurs $x_i$ qu'elle prend sont donc les valeurs de gain (ou de perte) possibles.`;
|
|
97
|
+
// case "diceSum":
|
|
98
|
+
// return `Chaque dé peut valoir $1$, $2$, $3$ ou $4$. Cela créé donc $16$ résultats possibles, par exemple $1+1=2$, $3+4=7$, etc... Détermine tous les résultats possibles.`;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const getCorrection = (identifiers) => {
|
|
102
|
+
const { params } = identifiers;
|
|
103
|
+
switch (params.id) {
|
|
104
|
+
case "coin":
|
|
105
|
+
return `On liste toutes les issues possibles :
|
|
106
|
+
|
|
107
|
+
- $2$ piles : le gain du joueur est alors $${multiply(2, params.a).toSimplificationTex()}$ points.
|
|
108
|
+
- $1$ pile, $1$ face : le gain du joueur est alors $${substract(params.a, params.b).toSimplificationTex()}$ points.
|
|
109
|
+
- $2$ faces: le gain du joueur est alors $${opposite(multiply(2, params.b)).toSimplificationTex()}$ points.
|
|
110
|
+
|
|
111
|
+
L'ensemble des valeurs possibles pour $X$ est donc :
|
|
112
|
+
|
|
113
|
+
$$
|
|
114
|
+
${getAnswer(identifiers)}
|
|
115
|
+
$$
|
|
116
|
+
`;
|
|
117
|
+
case "urne":
|
|
118
|
+
return `Le gain pour chaque tirage vaut :
|
|
119
|
+
|
|
120
|
+
- $${params.gb}$ si on tire une boule blanche ;
|
|
121
|
+
- $${params.gr}$ si on tire une boule rouge ;
|
|
122
|
+
- $${params.gn}$ si on tire une boule noire.
|
|
123
|
+
|
|
124
|
+
L'ensemble des valeurs possibles pour $X$ est donc :
|
|
125
|
+
|
|
126
|
+
$$
|
|
127
|
+
${getAnswer(identifiers)}
|
|
128
|
+
$$`;
|
|
129
|
+
case "diceMultiple":
|
|
130
|
+
return `Si on obtient un multiple de $${params.winningMultiple}$, on gagne $${params.gain}\\ €$, donc $X$ vaut $${params.gain}$ dans ce cas. Sinon, on perd $${params.loss}\\ €$, donc $X$ vaut $-${params.loss}$.
|
|
131
|
+
|
|
132
|
+
L'ensemble des valeurs possibles pour $X$ est donc :
|
|
133
|
+
|
|
134
|
+
$$
|
|
135
|
+
${getAnswer(identifiers)}
|
|
136
|
+
$$`;
|
|
137
|
+
case "cards":
|
|
138
|
+
return `Le gain pour chaque tirage vaut :
|
|
139
|
+
|
|
140
|
+
- $${params.gAs}$ si on tire un as ;
|
|
141
|
+
- $${params.gFigure}$ si on tire une figure ;
|
|
142
|
+
- $${params.gOther}$ si on tire une autre carte.
|
|
143
|
+
|
|
144
|
+
L'ensemble des valeurs possibles pour $X$ est donc :
|
|
145
|
+
|
|
146
|
+
$$
|
|
147
|
+
${getAnswer(identifiers)}
|
|
148
|
+
$$`;
|
|
149
|
+
// case "diceSum": {
|
|
150
|
+
// const results = [["\\ ", "1", "2", "3", "4"], ["1"], ["2"], ["3"], ["4"]];
|
|
151
|
+
// for (let i = 1; i < 5; i++) {
|
|
152
|
+
// for (let j = 1; j < 5; j++) {
|
|
153
|
+
// results[i][j] = (i + j).frenchify();
|
|
154
|
+
// }
|
|
155
|
+
// }
|
|
156
|
+
// return `Voici tous les résultats possibles en fonction du résultat de chaque dé :
|
|
157
|
+
// ${mdTable(results, true)}
|
|
158
|
+
// Les valeurs possibles pour $X$ sont donc :
|
|
159
|
+
// ${mdTable(getAnswerTable(identifiers), true)}`;
|
|
160
|
+
// }
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const getKeys = () => {
|
|
164
|
+
return ["lbrace", "semicolon", "rbrace"];
|
|
165
|
+
};
|
|
166
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
167
|
+
try {
|
|
168
|
+
const parsed = discreteSetParser(ans);
|
|
169
|
+
if (!parsed)
|
|
170
|
+
return false;
|
|
171
|
+
return parsed.simplify().toTex() === answer;
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
return handleVEAError(err);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const getRandomVariableSituationValuesQuestion = () => {
|
|
178
|
+
const params = buildRandomVariableSituation();
|
|
179
|
+
const identifiers = {
|
|
180
|
+
params,
|
|
181
|
+
};
|
|
182
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
183
|
+
};
|
|
184
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
185
|
+
return {
|
|
186
|
+
answer: getAnswer(identifiers),
|
|
187
|
+
instruction: getInstruction(identifiers),
|
|
188
|
+
keys: getKeys(identifiers),
|
|
189
|
+
answerFormat: "tex",
|
|
190
|
+
identifiers,
|
|
191
|
+
hint: getHint(identifiers),
|
|
192
|
+
correction: getCorrection(identifiers),
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
export const randomVariableSituationValues = {
|
|
196
|
+
id: "randomVariableSituationValues",
|
|
197
|
+
label: "Donner l'ensemble des valeurs possibles d'une variable aléatoire avec contexte",
|
|
198
|
+
isSingleStep: true,
|
|
199
|
+
generator: (nb, opts) => getDistinctQuestions(() => getRandomVariableSituationValuesQuestion(opts), nb),
|
|
200
|
+
qcmTimer: 60,
|
|
201
|
+
freeTimer: 60,
|
|
202
|
+
isAnswerValid,
|
|
203
|
+
getAnswer,
|
|
204
|
+
subject: "Mathématiques",
|
|
205
|
+
getInstruction,
|
|
206
|
+
getHint,
|
|
207
|
+
getCorrection,
|
|
208
|
+
getPropositions,
|
|
209
|
+
getQuestionFromIdentifiers,
|
|
210
|
+
hasHintAndCorrection: true,
|
|
211
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { SituationParams } from "./utils/randomVariableSituations.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
params: SituationParams;
|
|
5
|
+
};
|
|
6
|
+
export declare const randomVariableSituationVariance: Exercise<Identifiers>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=randomVariableSituationVariance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"randomVariableSituationVariance.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/randomVariable/randomVariableSituationVariance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAGL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAE7C,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AA4GF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAqBjE,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
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 { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
|
|
5
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
6
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
7
|
+
import { buildRandomVariableSituation, getRandomVariableSituation, } from "./utils/randomVariableSituations.js";
|
|
8
|
+
const getPropositions = (n, { answer }) => {
|
|
9
|
+
const propositions = [];
|
|
10
|
+
addValidProp(propositions, answer);
|
|
11
|
+
propWhile(propositions, n, () => {
|
|
12
|
+
tryToAddWrongProp(propositions, RationalConstructor.randomIrreductibleWithSign().toTree().toTex());
|
|
13
|
+
});
|
|
14
|
+
return shuffleProps(propositions, n);
|
|
15
|
+
};
|
|
16
|
+
const getAnswer = (identifiers) => {
|
|
17
|
+
const { params } = identifiers;
|
|
18
|
+
const va = getRandomVariableSituation(params).getVA();
|
|
19
|
+
return va.getVariance().simplify().toTex();
|
|
20
|
+
};
|
|
21
|
+
const getInstruction = (identifiers) => {
|
|
22
|
+
const { params } = identifiers;
|
|
23
|
+
const context = getRandomVariableSituation(params).getContext();
|
|
24
|
+
return (context +
|
|
25
|
+
`
|
|
26
|
+
|
|
27
|
+
Que vaut la variance $V(X)$ de $X$ ?
|
|
28
|
+
|
|
29
|
+
Donner la valeur exacte ou une valeur arrondie au centième.`);
|
|
30
|
+
};
|
|
31
|
+
const getHint = () => {
|
|
32
|
+
return `Dresse la loi de probabilité de $X$. Pour cela, détermine les valeurs possibles $x_i$ que peut prendre $X$, puis pour chaque valeur, calcule la probabilité $p_i$ associée.
|
|
33
|
+
|
|
34
|
+
Tu peux alors calculer l'espérance de $X$ par la formule :
|
|
35
|
+
|
|
36
|
+
$$
|
|
37
|
+
E(X) = x_1\\times p_1 + \\ldots + x_n\\times p_n
|
|
38
|
+
$$
|
|
39
|
+
|
|
40
|
+
La variance $V(X)$ s'obtient par la formule :
|
|
41
|
+
|
|
42
|
+
$$
|
|
43
|
+
V(X) = p_1(x_1-E(X))^2 + \\ldots + p_n(x_n-E(X))^2
|
|
44
|
+
$$
|
|
45
|
+
`;
|
|
46
|
+
};
|
|
47
|
+
const getCorrection = (identifiers) => {
|
|
48
|
+
const { params } = identifiers;
|
|
49
|
+
const va = getRandomVariableSituation(params).getVA();
|
|
50
|
+
return `On dresse la loi de probabilité de $X$ :
|
|
51
|
+
|
|
52
|
+
${va.getLawMdTable()}
|
|
53
|
+
|
|
54
|
+
Puis on calcule l'espérance :
|
|
55
|
+
|
|
56
|
+
${alignTex([
|
|
57
|
+
["E(X)", "=", va.getAverage().toTex()],
|
|
58
|
+
["", "=", va.getAverage().simplify().toTex()],
|
|
59
|
+
])}
|
|
60
|
+
|
|
61
|
+
Enfin, on calcule la variance :
|
|
62
|
+
|
|
63
|
+
${alignTex([
|
|
64
|
+
["V(X)", "=", va.getVariance().toTex()],
|
|
65
|
+
["", "=", va.getVariance().simplify().toTex()],
|
|
66
|
+
])}`;
|
|
67
|
+
};
|
|
68
|
+
const getKeys = () => {
|
|
69
|
+
return [];
|
|
70
|
+
};
|
|
71
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
72
|
+
try {
|
|
73
|
+
return rationalVEA(ans, answer);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
return handleVEAError(err);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const getRandomVariableSituationAverageQuestion = () => {
|
|
80
|
+
const params = buildRandomVariableSituation();
|
|
81
|
+
const identifiers = {
|
|
82
|
+
params,
|
|
83
|
+
};
|
|
84
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
85
|
+
};
|
|
86
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
87
|
+
return {
|
|
88
|
+
answer: getAnswer(identifiers),
|
|
89
|
+
instruction: getInstruction(identifiers),
|
|
90
|
+
keys: getKeys(identifiers),
|
|
91
|
+
answerFormat: "tex",
|
|
92
|
+
identifiers,
|
|
93
|
+
hint: getHint(identifiers),
|
|
94
|
+
correction: getCorrection(identifiers),
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
export const randomVariableSituationVariance = {
|
|
98
|
+
id: "randomVariableSituationVariance",
|
|
99
|
+
connector: "=",
|
|
100
|
+
label: "Calculer la variance $V(X)$ d'une variable aléatoire dans un contexte",
|
|
101
|
+
isSingleStep: true,
|
|
102
|
+
generator: (nb, opts) => getDistinctQuestions(() => getRandomVariableSituationAverageQuestion(opts), nb),
|
|
103
|
+
qcmTimer: 60,
|
|
104
|
+
freeTimer: 60,
|
|
105
|
+
getPropositions,
|
|
106
|
+
isAnswerValid,
|
|
107
|
+
subject: "Mathématiques",
|
|
108
|
+
getHint,
|
|
109
|
+
getCorrection,
|
|
110
|
+
getAnswer,
|
|
111
|
+
getQuestionFromIdentifiers,
|
|
112
|
+
hasHintAndCorrection: true,
|
|
113
|
+
};
|
|
@@ -25,7 +25,7 @@ const getInstruction = (identifiers) => {
|
|
|
25
25
|
const va = new RandomVariable(xValuesIds.map((e) => reifyAlgebraic(e)), yValuesIds.map((e) => reifyAlgebraic(e)));
|
|
26
26
|
return `Soit $X$ une variable aléatoire dont la loi de probabilités est donnée ci-dessous.
|
|
27
27
|
|
|
28
|
-
${va.
|
|
28
|
+
${va.getLawMdTable()}
|
|
29
29
|
|
|
30
30
|
Que vaut l'écart type $\\sigma(X)$ de $X$ ?
|
|
31
31
|
|
|
@@ -27,7 +27,7 @@ const getInstruction = (identifiers) => {
|
|
|
27
27
|
const va = new RandomVariable(xValuesIds.map((e) => reifyAlgebraic(e)), yValuesIds.map((e) => reifyAlgebraic(e)));
|
|
28
28
|
return `Soit $X$ une variable aléatoire dont la loi de probabilités est donnée ci-dessous.
|
|
29
29
|
|
|
30
|
-
${va.
|
|
30
|
+
${va.getLawMdTable()}
|
|
31
31
|
|
|
32
32
|
Que vaut la variance $V(X)$ de $X$ ?
|
|
33
33
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Génère une loi de probabilité pour une variable aléatoire X
|
|
3
|
+
* dans le contexte d'un jeu de hasard fictif (valeurs en euros).
|
|
4
|
+
*
|
|
5
|
+
* Contraintes :
|
|
6
|
+
* - Les x_i sont des entiers, avec au moins un négatif et au moins un positif
|
|
7
|
+
* - Les p_i sont dans ]0, 1[, à 3 décimales maximum
|
|
8
|
+
* - ∑ p_i = 1 (somme des probabilités)
|
|
9
|
+
* - ∑ x_i * p_i = expectedValue (espérance cible, entier)
|
|
10
|
+
*/
|
|
11
|
+
interface ProbabilityEntry {
|
|
12
|
+
x: number;
|
|
13
|
+
p: number;
|
|
14
|
+
}
|
|
15
|
+
type ProbabilityLaw = ProbabilityEntry[];
|
|
16
|
+
/**
|
|
17
|
+
* Génère une loi de probabilité pour un jeu de hasard fictif.
|
|
18
|
+
*
|
|
19
|
+
* @param count Nombre de valeurs distinctes de X (3 à 10)
|
|
20
|
+
* @param expectedValue Espérance cible — entier strictement compris entre
|
|
21
|
+
* min(x_i) et max(x_i). Pour un jeu "légèrement perdant"
|
|
22
|
+
* typique, une valeur négative proche de 0 convient.
|
|
23
|
+
* @returns Tableau trié { x, p }[] représentant la loi
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* generateProbabilityLaw(5, -1)
|
|
27
|
+
* // [{ x: -10, p: 0.124 }, { x: -2, p: 0.253 }, { x: 1, p: 0.387 }, ...]
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateProbabilityLaw(count: number, expectedValue: number): ProbabilityLaw;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=buildVAOfGivenAverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildVAOfGivenAverage.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/probaStat/randomVariable/utils/buildVAOfGivenAverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,UAAU,gBAAgB;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,KAAK,cAAc,GAAG,gBAAgB,EAAE,CAAC;AA4LzC;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,GACpB,cAAc,CAYhB"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Génère une loi de probabilité pour une variable aléatoire X
|
|
3
|
+
* dans le contexte d'un jeu de hasard fictif (valeurs en euros).
|
|
4
|
+
*
|
|
5
|
+
* Contraintes :
|
|
6
|
+
* - Les x_i sont des entiers, avec au moins un négatif et au moins un positif
|
|
7
|
+
* - Les p_i sont dans ]0, 1[, à 3 décimales maximum
|
|
8
|
+
* - ∑ p_i = 1 (somme des probabilités)
|
|
9
|
+
* - ∑ x_i * p_i = expectedValue (espérance cible, entier)
|
|
10
|
+
*/
|
|
11
|
+
// ── Utilitaires ──────────────────────────────────────────────────────────────
|
|
12
|
+
function round(value, decimals) {
|
|
13
|
+
const factor = Math.pow(10, decimals);
|
|
14
|
+
return Math.round(value * factor) / factor;
|
|
15
|
+
}
|
|
16
|
+
function randomInt(min, max) {
|
|
17
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
18
|
+
}
|
|
19
|
+
// ── Génération des valeurs x_i ───────────────────────────────────────────────
|
|
20
|
+
function generateXValues(count) {
|
|
21
|
+
const negativePool = [-50, -20, -10, -5, -3, -2, -1];
|
|
22
|
+
const positivePool = [1, 2, 3, 5, 10, 20, 50, 100, 200];
|
|
23
|
+
const values = new Set();
|
|
24
|
+
// Garantir au moins une valeur négative et une positive
|
|
25
|
+
values.add(negativePool[randomInt(0, negativePool.length - 1)]);
|
|
26
|
+
values.add(positivePool[randomInt(0, positivePool.length - 1)]);
|
|
27
|
+
const allPool = [...negativePool, 0, ...positivePool];
|
|
28
|
+
let attempts = 0;
|
|
29
|
+
while (values.size < count && attempts < 200) {
|
|
30
|
+
values.add(allPool[randomInt(0, allPool.length - 1)]);
|
|
31
|
+
attempts++;
|
|
32
|
+
}
|
|
33
|
+
return Array.from(values)
|
|
34
|
+
.sort((a, b) => a - b)
|
|
35
|
+
.slice(0, count);
|
|
36
|
+
}
|
|
37
|
+
// ── Cœur : génération des probabilités avec espérance cible ──────────────────
|
|
38
|
+
/**
|
|
39
|
+
* Résout le problème de trouver des p_i à 3 décimales vérifiant :
|
|
40
|
+
* (1) ∑ p_i = 1
|
|
41
|
+
* (2) ∑ x_i * p_i = expectedValue
|
|
42
|
+
* (3) p_i ∈ ]0, 1[
|
|
43
|
+
*
|
|
44
|
+
* Stratégie en millièmes entiers (travailler sur q_i = 1000 * p_i ∈ ℤ) :
|
|
45
|
+
*
|
|
46
|
+
* Étape A — Point de départ aléatoire
|
|
47
|
+
* On tire des poids w_i aléatoires et on les normalise pour obtenir
|
|
48
|
+
* une solution approchée de (1).
|
|
49
|
+
*
|
|
50
|
+
* Étape B — Correction vers l'espérance cible
|
|
51
|
+
* On dispose d'un degré de liberté dans le plan des solutions :
|
|
52
|
+
* ∑ δ_i = 0 (conserver la somme à 1)
|
|
53
|
+
* ∑ x_i δ_i = ΔE (corriger l'espérance)
|
|
54
|
+
* La correction de norme minimale dans ce plan est :
|
|
55
|
+
*
|
|
56
|
+
* v' = x - (x·u) u avec u = (1/√n, …, 1/√n)
|
|
57
|
+
* v = v' / ‖v'‖
|
|
58
|
+
* δ = β · v avec β = ΔE / (x · v)
|
|
59
|
+
*
|
|
60
|
+
* Étape C — Arrondi contrôlé en millièmes
|
|
61
|
+
* On arrondit chaque q_i = round(1000 * (p_i + δ_i)), puis on corrige
|
|
62
|
+
* les deux résidus (somme et espérance) en cherchant la paire (i, j)
|
|
63
|
+
* et les deltas ±1 millième qui réduisent simultanément les deux écarts.
|
|
64
|
+
*/
|
|
65
|
+
function generateProbabilities(xValues, expectedValue) {
|
|
66
|
+
const SCALE = 1000; // travail en millièmes
|
|
67
|
+
const n = xValues.length;
|
|
68
|
+
const ETarget = expectedValue * SCALE; // espérance en millièmes·unités
|
|
69
|
+
// ── Vérification de faisabilité ──────────────────────────────────────────
|
|
70
|
+
// Avec p_i > 0 et ∑ p_i = 1, l'espérance est une combinaison convexe stricte
|
|
71
|
+
// des x_i, donc E ∈ ]min(x), max(x)[ est nécessaire et suffisant.
|
|
72
|
+
const xMin = Math.min(...xValues);
|
|
73
|
+
const xMax = Math.max(...xValues);
|
|
74
|
+
if (expectedValue <= xMin || expectedValue >= xMax) {
|
|
75
|
+
throw new Error(`Espérance cible ${expectedValue} hors de l'intervalle ouvert ` +
|
|
76
|
+
`]${xMin}, ${xMax}[ défini par les valeurs de X. ` +
|
|
77
|
+
`Choisissez une espérance dans cet intervalle.`);
|
|
78
|
+
}
|
|
79
|
+
const MAX_ATTEMPTS = 3000;
|
|
80
|
+
for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt++) {
|
|
81
|
+
// ── Étape A : point de départ aléatoire normalisé ──────────────────────
|
|
82
|
+
const weights = Array.from({ length: n }, () => randomInt(1, 20));
|
|
83
|
+
const wSum = weights.reduce((a, b) => a + b, 0);
|
|
84
|
+
let p = weights.map((w) => w / wSum);
|
|
85
|
+
// ── Étape B : correction vers l'espérance cible ────────────────────────
|
|
86
|
+
// Direction orthogonale à u = (1/√n,…,1/√n) dans l'espace de x
|
|
87
|
+
const sqrtN = Math.sqrt(n);
|
|
88
|
+
const u = Array(n).fill(1 / sqrtN);
|
|
89
|
+
const xDotU = xValues.reduce((acc, xi, i) => acc + xi * u[i], 0);
|
|
90
|
+
const vPrime = xValues.map((xi, i) => xi - xDotU * u[i]);
|
|
91
|
+
const vNorm = Math.sqrt(vPrime.reduce((acc, vi) => acc + vi * vi, 0));
|
|
92
|
+
if (vNorm < 1e-10)
|
|
93
|
+
continue;
|
|
94
|
+
const v = vPrime.map((vi) => vi / vNorm);
|
|
95
|
+
const ECurrent = p.reduce((acc, pi, i) => acc + pi * xValues[i], 0);
|
|
96
|
+
const deltaE = expectedValue - ECurrent;
|
|
97
|
+
const xDotV = xValues.reduce((acc, xi, i) => acc + xi * v[i], 0);
|
|
98
|
+
if (Math.abs(xDotV) < 1e-10)
|
|
99
|
+
continue;
|
|
100
|
+
const beta = deltaE / xDotV;
|
|
101
|
+
p = p.map((pi, i) => pi + beta * v[i]);
|
|
102
|
+
// Rejeter si des probabilités sont hors ]0, 1[
|
|
103
|
+
if (p.some((pi) => pi <= 0 || pi >= 1))
|
|
104
|
+
continue;
|
|
105
|
+
// ── Étape C : arrondi contrôlé en millièmes ────────────────────────────
|
|
106
|
+
let q = p.map((pi) => Math.round(pi * SCALE));
|
|
107
|
+
q = q.map((qi) => Math.max(qi, 1)); // garantir q_i >= 1
|
|
108
|
+
// Correction itérative des deux résidus (somme et espérance)
|
|
109
|
+
let converged = false;
|
|
110
|
+
for (let iter = 0; iter < 500; iter++) {
|
|
111
|
+
const sumQ = q.reduce((a, b) => a + b, 0);
|
|
112
|
+
const espQ = q.reduce((acc, qi, i) => acc + qi * xValues[i], 0);
|
|
113
|
+
const dS = SCALE - sumQ; // résidu de somme (en millièmes)
|
|
114
|
+
const dE = ETarget - espQ; // résidu d'espérance (en millièmes·€)
|
|
115
|
+
if (dS === 0 && dE === 0) {
|
|
116
|
+
converged = true;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
// Chercher la paire (i, j) et les deltas entiers (d1, d2) ∈ {-1,0,1}²
|
|
120
|
+
// qui minimisent |dS_new| + λ|dE_new| tout en respectant q_i ≥ 1.
|
|
121
|
+
let bestScore = Infinity;
|
|
122
|
+
let bestMove = null;
|
|
123
|
+
for (let i = 0; i < n; i++) {
|
|
124
|
+
for (let j = i === -1 ? 0 : i + 1; j < n; j++) {
|
|
125
|
+
if (i === j)
|
|
126
|
+
continue;
|
|
127
|
+
for (const d1 of [-1, 0, 1]) {
|
|
128
|
+
for (const d2 of [-1, 0, 1]) {
|
|
129
|
+
if (d1 === 0 && d2 === 0)
|
|
130
|
+
continue;
|
|
131
|
+
const newQi = q[i] + d1;
|
|
132
|
+
const newQj = q[j] + d2;
|
|
133
|
+
if (newQi < 1 || newQj < 1 || newQi >= SCALE || newQj >= SCALE)
|
|
134
|
+
continue;
|
|
135
|
+
const newDS = Math.abs(dS - (d1 + d2));
|
|
136
|
+
const newDE = Math.abs(dE - (xValues[i] * d1 + xValues[j] * d2));
|
|
137
|
+
// Priorité absolue à réduire |dS|, puis |dE|
|
|
138
|
+
const score = newDS * 1_000_000 + newDE;
|
|
139
|
+
if (score < bestScore) {
|
|
140
|
+
bestScore = score;
|
|
141
|
+
bestMove = { i, j, d1, d2 };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (!bestMove)
|
|
148
|
+
break;
|
|
149
|
+
q[bestMove.i] += bestMove.d1;
|
|
150
|
+
q[bestMove.j] += bestMove.d2;
|
|
151
|
+
}
|
|
152
|
+
if (!converged)
|
|
153
|
+
continue;
|
|
154
|
+
// ── Validation finale ──────────────────────────────────────────────────
|
|
155
|
+
const finalSum = q.reduce((a, b) => a + b, 0);
|
|
156
|
+
const finalEsp = q.reduce((acc, qi, i) => acc + qi * xValues[i], 0);
|
|
157
|
+
if (finalSum !== SCALE)
|
|
158
|
+
continue;
|
|
159
|
+
if (finalEsp !== ETarget)
|
|
160
|
+
continue;
|
|
161
|
+
if (q.some((qi) => qi <= 0 || qi >= SCALE))
|
|
162
|
+
continue;
|
|
163
|
+
return q.map((qi) => round(qi / SCALE, 3));
|
|
164
|
+
}
|
|
165
|
+
throw new Error(`Impossible de générer une loi valide après ${MAX_ATTEMPTS} tentatives. ` +
|
|
166
|
+
`Essayez avec une espérance différente ou davantage de valeurs.`);
|
|
167
|
+
}
|
|
168
|
+
// ── Point d'entrée public ─────────────────────────────────────────────────────
|
|
169
|
+
/**
|
|
170
|
+
* Génère une loi de probabilité pour un jeu de hasard fictif.
|
|
171
|
+
*
|
|
172
|
+
* @param count Nombre de valeurs distinctes de X (3 à 10)
|
|
173
|
+
* @param expectedValue Espérance cible — entier strictement compris entre
|
|
174
|
+
* min(x_i) et max(x_i). Pour un jeu "légèrement perdant"
|
|
175
|
+
* typique, une valeur négative proche de 0 convient.
|
|
176
|
+
* @returns Tableau trié { x, p }[] représentant la loi
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* generateProbabilityLaw(5, -1)
|
|
180
|
+
* // [{ x: -10, p: 0.124 }, { x: -2, p: 0.253 }, { x: 1, p: 0.387 }, ...]
|
|
181
|
+
*/
|
|
182
|
+
export function generateProbabilityLaw(count, expectedValue) {
|
|
183
|
+
if (count < 3 || count > 10) {
|
|
184
|
+
throw new Error("Le nombre de valeurs doit être compris entre 3 et 10.");
|
|
185
|
+
}
|
|
186
|
+
if (!Number.isInteger(expectedValue)) {
|
|
187
|
+
throw new Error("L'espérance cible doit être un entier.");
|
|
188
|
+
}
|
|
189
|
+
const xValues = generateXValues(count);
|
|
190
|
+
const probabilities = generateProbabilities(xValues, expectedValue);
|
|
191
|
+
return xValues.map((x, i) => ({ x, p: probabilities[i] }));
|
|
192
|
+
}
|
|
@@ -1,12 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { RandomVariable } from "../../../../../math/probability/randomVariable.js";
|
|
2
|
+
type UrneParams = {
|
|
3
|
+
b: number;
|
|
4
|
+
r: number;
|
|
5
|
+
n: number;
|
|
6
|
+
gb: number;
|
|
7
|
+
gr: number;
|
|
8
|
+
gn: number;
|
|
9
|
+
};
|
|
10
|
+
type CoinParams = {
|
|
11
|
+
b: number;
|
|
12
|
+
a: number;
|
|
13
|
+
n: number;
|
|
14
|
+
};
|
|
15
|
+
type DiceMultipleParams = {
|
|
16
|
+
n: number;
|
|
17
|
+
winningMultiple: number;
|
|
18
|
+
gain: number;
|
|
19
|
+
loss: number;
|
|
20
|
+
};
|
|
21
|
+
type CardsParams = {
|
|
22
|
+
gAs: number;
|
|
23
|
+
gFigure: number;
|
|
24
|
+
gOther: number;
|
|
25
|
+
};
|
|
26
|
+
export type SituationParams = (UrneParams & {
|
|
27
|
+
id: "urne";
|
|
28
|
+
}) | (CoinParams & {
|
|
29
|
+
id: "coin";
|
|
30
|
+
}) | (DiceMultipleParams & {
|
|
31
|
+
id: "diceMultiple";
|
|
32
|
+
}) | (CardsParams & {
|
|
33
|
+
id: "cards";
|
|
34
|
+
});
|
|
35
|
+
export declare const getRandomVariableSituation: (params: SituationParams) => {
|
|
36
|
+
getContext: () => string;
|
|
37
|
+
getVA: () => RandomVariable;
|
|
38
|
+
};
|
|
39
|
+
export declare const buildRandomVariableSituation: () => SituationParams;
|
|
40
|
+
export {};
|
|
12
41
|
//# sourceMappingURL=randomVariableSituations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randomVariableSituations.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"randomVariableSituations.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAU1E,KAAK,UAAU,GAAG;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAqDF,KAAK,UAAU,GAAG;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAmEF,KAAK,kBAAkB,GAAG;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAkCF,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AA4BF,MAAM,MAAM,eAAe,GACvB,CAAC,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,GAC7B,CAAC,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,GAC7B,CAAC,kBAAkB,GAAG;IAAE,EAAE,EAAE,cAAc,CAAA;CAAE,CAAC,GAC7C,CAAC,WAAW,GAAG;IAAE,EAAE,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAIpC,eAAO,MAAM,0BAA0B,GAAI,QAAQ,eAAe;;;CAajE,CAAC;AAEF,eAAO,MAAM,4BAA4B,QAAO,eAkB/C,CAAC"}
|