$\text{Choose view:}$

if label is bolded, it needs to be in a slightly different location

\text{Click to remove}

#4D4D4D

$\text{Check}$

$\text{NEW COOKIES}$

Fix position and allow selection for all text objects

Empty all input boxes

\text{This is the answer.}

$\text{The probability is}$

Reset app

\text{This is the error specific hint}

#006758

#B00020

#252525

#757575

#949494

#E44461

#DA2570

#E66B9E

#3A6ED6

#5991FF

#008475

#0F8538

#00a83c

#5145A8

#6557D2

#8575FF

#903D14

#BD6C43

#C75000

#E07415

\text{This is the general hint}

#eeeeee

#2E006758

#2EB00020

$\text{RANDOM COOKIE}$

\text\underline{Probability each Ingredient is Selected}

\text\underline{Frequency each Ingredient is Selected}

$\text{RANDOM COOKIE}$

$\text{NEW COOKIES}$

allRandomSeeds = RandomUniform(0, 0.99, 200)
axisOrigin: (0.5, 0)
cookiesSelected: {}
currentCookieIndex = Element(cookiesSelected, Length[cookiesSelected])
cookie5: {2, 5}
cookie13: {4}
cookie11: {2, 6}
cookie6: {4, 6}
cookie1: {1, 2}
cookie2: {1, 2, 3, 5}
cookie12: {3, 5}
cookie3: {2, 3, 5}
cookie4: {2, 4}
cookie10: {6}
cookie7: {1, 4}
cookie8: {1, 4, 6}
cookie9: {2}
cookieIngredients: {cookie1, cookie2, cookie3, cookie4, cookie5, cookie6, cookie7, cookie8, cookie9, cookie10, cookie11, cookie12, cookie13}
currentCookieIngredientsIndex: cookieIngredients(currentCookieIndex)
animateControl = 4 (slider from 0 to maxAnimate, step 0.01)
maxAnimate: 4
highlightLabel = Zip(3 < animateControl < maxAnimate ∧ Defined[IndexOf[A, currentCookieIngredientsIndex]], A, {1, 2, 3, 4, 5, 6})
numTrials = 0 (slider from 0 to 100, step 1)
countQuestion = 0
numRandoms: 100
maxRandIndex: Mod[(countQuestion * numRandoms), Length[allRandomSeeds] - numRandoms + 1] + numRandoms
currentRandomSeeds = Take(allRandomSeeds, maxRandIndex - numRandoms + 1, maxRandIndex)
ImageStart = (1.3151678117937804, 2.262022248044844)
cookieImages: {picRaspberries, picDelectables, picCaramels, picCrispies, picPeanutButter, picMarshmallows, picLemons, picCheerfuls, picYumYums, picMint, picToasties, picToffees, picShortbread}
numCookies = If(countQuestion ≤ 1, 7, 2 + floor((currentRandomSeeds(2) * 12)))
orderIndex: 1 + floor((currentRandomSeeds(2) * 4))
possibleOrders: {{1, 13, 2, 12, 3, 11, 6, 10, 5, 9, 4, 8, 7}, {6, 5, 4, 1, 2, 3, 10, 11, 12, 13, 7, 8, 9}, {9, 1, 2, 8, 7, 11, 12, 3, 4, 13, 6, 5, 10}, {2, 4, 6, 8, 10, 11, 12, 13, 9, 7, 5, 3, 1}}
cookieIndex = Take(Element[possibleOrders, orderIndex], 1, numCookies)
chosenCookieImages = Zip(Element[cookieImages, A], A, cookieIndex)
viewOptions: {"$\textsf{Probability\phantom{m}}$", "$\textsf{Frequency\phantom{m}}$"}
bagBottomRight = PixelsToPoint(Corner[1], Corner[3], Corner[5], (800 - 16, 500 - 16 - 36 - 16))
BagBottomLeft = PixelsToPoint(Corner[1], Corner[3], Corner[5], (435, 500 - 16 - 36 - 16))
imgSize: (x(bagBottomRight) - x(BagBottomLeft)) / 6
imgSpace: imgSize / 5
CookieStart: BagBottomLeft + (imgSize + imgSpace / 2, imgSpace)
listFirstCookieLocations: {CookieStart, CookieStart + (imgSize + imgSpace, 0), CookieStart + (2 * (imgSize + imgSpace, 0)), CookieStart + (3 * (imgSize + imgSpace, 0)), CookieStart + (imgSize / 2, imgSize + imgSpace), CookieStart + (imgSize / 2 + imgSize + imgSpace, imgSize + imgSpace), CookieStart + (imgSize / 2 + (2 * (imgSize + imgSpace)), imgSize + imgSpace)}
listSecondCookieLocations = Translate(listFirstCookieLocations, Vector[CookieStart, CookieStart + (0, (imgSize * 2) + (imgSpace * 2))])
listCookieLocations = Join({listFirstCookieLocations, listSecondCookieLocations})
TranslatedCookieImages = Zip(Translate[A, Vector[B]], A, chosenCookieImages, Vector[B], Zip[Vector[ImageStart, K], K, listCookieLocations])
cookieImg13 = Element(TranslatedCookieImages, 13)
cookieImg12 = Element(TranslatedCookieImages, 12)
cookieImg11 = Element(TranslatedCookieImages, 11)
cookieImg10 = Element(TranslatedCookieImages, 10)
cookieImg9 = Element(TranslatedCookieImages, 9)
cookieImg8 = Element(TranslatedCookieImages, 8)
cookieImg7 = Element(TranslatedCookieImages, 7)
cookieImg6 = Element(TranslatedCookieImages, 6)
cookieImg5 = Element(TranslatedCookieImages, 5)
cookieImg4 = Element(TranslatedCookieImages, 4)
cookieImg3 = Element(TranslatedCookieImages, 3)
cookieImg2 = Element(TranslatedCookieImages, 2)
cookieImg1 = Element(TranslatedCookieImages, 1)
onboardingPointPixels: PointToPixels[listCookieLocations(numCookies) + (imgSize / 2, imgSize), Corner[1], Corner[3], Corner[5]] + (-12, -8)
horizontalLabelLoc = Zip(axisOrigin + (0.5 + A, If[B, 0.45, 0.2]), A, {0, 1, 2, 3, 4, 5}, B, highlightLabel)
currentCookieLocation = (7.124141083485054, 4.801023733134417)
middleCookieLocation: currentCookieLocation + (imgSize / 2, imgSize / 2)
currentCookieIngredientsLocFinal = Zip(horizontalLabelLoc(A), A, currentCookieIngredientsIndex)
input1 = NaN
randomNum1: 3 + floor((currentRandomSeeds(1) * 15))
onboarding = false
inputSaved: {NaN}
input2 = 1 (slider from -5 to 5)
inputCurrent: {viewOptions, cookieImg1, cookieImg2, cookieImg3, cookieImg4, cookieImg5, cookieImg6, cookieImg7, cookieImg8, cookieImg9, cookieImg10, cookieImg11, cookieImg12, cookieImg13}
randomNum2: randomNum1 + 2 + floor((currentRandomSeeds(2) * 10))
validate = false
showanswer = false
showsolution = false
tries = 0
countCorrect = 0
showhint = false
InputBox1 = Textfield(input1)
correct: abs(input1 - 1 / numCookies) ≤ 0.005
isTypicalError: input2 ≟ input1 + 1
showbuttons = true
typicalError1: 0
typicalError2: 0
showhinttypicalerror = false
labelBtnValidate: "\text{CHECK (" + (LaTeX[3 - tries]) + ")}"
enableBtnValidate: inputCurrent ≠ inputSaved ∧ inputCurrent ≟ RemoveUndefined[inputCurrent] ∧ (¬onboarding)
pixelsRight: 16
pixelsLeft: 16
pixelsBottom: 16
pixelsTop: 24
textHint: "\text{\color{" + (LaTeX[colorOrange]) + "}\bold{Hint}\\" + (LaTeX[If[showhinttypicalerror, helpTextHintTypicalError]]) + "" + (LaTeX[If[showhint ∧ showhinttypicalerror, "\\"]]) + "" + (LaTeX[If[showhint, helpTextHint]]) + "}"
layoutY: 270
layoutX: 16
layoutAppSize = Corner(5)
textFeedback: "" + (LaTeX[If[correct, "$\text{✓ Correct}$", "$\text{✕ " + (If[tries < 3, "Try again", "Maybe next time"]) + "}$"]]) + ""
pulsingSpeed: 8
pulsing = 0.7 (slider from 0 to 1, step 0.1)
haloPixels: (pulsing * 7)
onboardingDisplayText: "" + (LaTeX[onboardingText]) + ""
layoutOnboarding = PointToPixels(Corner[onboardingDisplayText, 2], Corner[1], Corner[3], Corner[5])
onboardingX: x(onboardingPointPixels)
onboardingY: y(onboardingPointPixels)
onboardingCase: 4
OnboardingTextOffset = onboardingTextOffset(Corner[onboardingText, 1], Corner[onboardingText, 3], onboardingCase, Corner[1], Corner[3], Corner[5])
cookieNames: {"Raspberry", "Delectable", "Caramel", "Crispy", "Peanut Butter", "Marshmallow", "Lemon", "Cheerful", "Yum-Yum", "Mint", "Toasty", "Toffee", "Shortbread"}
chosenCookieNames = Zip(Element[cookieNames, A], A, cookieIndex)
chosenCookieIndex: cookieIndex(1 + floor((currentRandomSeeds(Mod[4 + numTrials, numRandoms]) * numCookies)))
chosenCookies = Element(cookieNames, chosenCookieIndex)
inputBoxLabel: "\textsf{Probability of pulling a " + (LaTeX[chosenCookies]) + " cookie is}"
labelLength: ((x(Corner[inputBoxLabel, 2]) - x(Corner[inputBoxLabel, 1])) * x(layoutAppSize) / (x(Corner[2]) - x(Corner[1])))
imageLabel: "\text{" + (LaTeX[chosenCookies]) + " Cookie}"
textSolution: "\textsf{\bold{Possible Solution}}\\
\textsf{The probability that they pull a " + (LaTeX[chosenCookies]) + " }\\
\textsf{Cookie is \dfrac{1}{" + (LaTeX[numCookies]) + "} because there are " + (LaTeX[numCookies]) + " equally likely}\\
\textsf{outcomes in the sample space.}"
textQuestion: "\textsf{A scout put " + (LaTeX[numCookies]) + " different cookies in a bag. The scout removes one cookie at a time, records the}\\
\textsf{ingredients, and replaces it before removing another cookie.}\\"
possibleIngredients: {"jam", "chocolate", "caramel", "icing sugar", "toffee", "sprinkles"}
ingredientFrequencyList = Flatten(Zip[Element[cookieIngredients, K], K, Take[cookiesSelected, 1, If[animateControl ≟ maxAnimate, Length[cookiesSelected], Length[cookiesSelected] - 1]]])
currentCookieLocationBag = Element(listCookieLocations, IndexOf[currentCookieIndex, cookieIndex])
graphHeight: 4
axisHeight: 4
horizontalAxis = Segment(axisOrigin, (Length[possibleIngredients], 0) + axisOrigin)
horizontalLines = Sequence(Segment[axisOrigin + (0, ((0.1 * k) * axisHeight)), axisOrigin + (Length[possibleIngredients], ((0.1 * k) * axisHeight))], k, 1, 10)
verticalAxis = Segment(axisOrigin, (x(axisOrigin), axisHeight + 0.25))
verticalLabelsPercent = Zip(Text[A, B + (-0.05, 0.05), true, true, -1, 0], A, Sequence[(k * 0.2), k, 1, 5], B, Sequence[axisOrigin + (k * (0, (0.2 * axisHeight))), k, 1, 5])
horizontalTicks = Sequence(Segment[axisOrigin + (-0.1, ((0.2 * k) * axisHeight)), axisOrigin + (0.1, ((0.2 * k) * axisHeight))], k, 1, 5)
animateCookie = Min(1, animateControl)
animateIngredientsA = Min(Max[0, animateControl - 2], 1)
cookieVector = Vector(currentCookieLocationBag, currentCookieLocation)
chosenCookieImage = Translate(Element[cookieImages, currentCookieIndex], Vector[ImageStart, currentCookieLocationBag + (animateCookie * cookieVector)])
currentCookieIngredients = Zip(possibleIngredients(A), A, currentCookieIngredientsIndex)
currentCookieIngredientsVec = Zip(Vector[middleCookieLocation, A], A, currentCookieIngredientsLocFinal)
ingredientObservations = Sequence(Length[KeepIf[x ≟ A, ingredientFrequencyList]], A, 1, 6)
numTrialsFinal = If(animateControl ≟ maxAnimate, numTrials, numTrials - 1)
ingredientProbability = Zip((A / numTrialsFinal * axisHeight), A, ingredientObservations)
barChartPercents = BarChart({1, 2, 3, 4, 5, 6}, ingredientProbability, 0.5)
speed: 3
textCountTrials: "\text{Number of Cookies Tested: \textbf\textcolor{" + (LaTeX[colorPink]) + "}{" + (LaTeX[numTrials]) + "} }"
frequencyHeight = If(Max[ingredientObservations] ≤ 5, 5, (ceil(Max[ingredientObservations] / 10) * 10))
barChartFrequency = BarChart(ingredientFrequencyList, 0.5, axisHeight / frequencyHeight)
verticalLabelsFrequency = Zip(Text[A, B + (-0.05, 0.05), true, true, -1, 0], A, Sequence[(k * frequencyHeight / 5), k, 1, 5], B, Sequence[axisOrigin + (k * (0, (0.2 * axisHeight))), k, 1, 5])
showProbabilityView: SelectedIndex[viewOptions] ≟ 1
a: SelectedIndex[viewOptions] ≟ 1
b: SelectedIndex[viewOptions] ≟ 1
c: SelectedIndex[viewOptions] ≟ 1
BagTopLeft = PixelsToPoint(Corner[1], Corner[3], Corner[5], (435, 60))
tabOrder: {textQuestion, viewOptions, graphLabelProbability, graphLabelFrequency, barChartPercents, barChartFrequency, textCountTrials, cookieImg1, cookieImg2, cookieImg3, cookieImg4, cookieImg5, cookieImg6, cookieImg7, cookieImg8, cookieImg9, cookieImg10, cookieImg11, cookieImg12, cookieImg13, btnNew}
pulsingCircle = expandCircle(listCookieLocations(numCookies) + (imgSize / 2, imgSize / 2), 26 + (8 * pulsing), Corner[1], Corner[3], Corner[5])
cmdUnfixCookieImgs = Zip((("SetFixed(cookieImg" * A) * ",true,true)"), A, Sequence[13])
cmdFixCookieImgs = Zip((("SetFixed(cookieImg" * A) * ",true,false)"), A, Sequence[13])
animateIngredientsB = Min(Max[0, animateControl - 1], 1)
cookieStartOffsets: (0.7 * Element[{{0}, {-0.5, 0.5}, {-1, 0, 1}, {-1.5, -0.5, 0.5, 1.5}}, Length[currentCookieIngredients]])
ingredientStartPositions = Zip(middleCookieLocation + (A, -0.5), A, cookieStartOffsets)
currentCookieIngredientsText = Zip(Text[RotateText[A, pi / 2], B + (animateIngredientsA * (C - B)), true, true, 0, -1], A, currentCookieIngredients, B, ingredientStartPositions, C, currentCookieIngredientsLocFinal)
horizonalLabels = Zip(Text[((If[C, "\textbf{", ""] * RotateText[A, pi / 2]) * If[C, "}", ""]), B, true, true, 0, -1], A, possibleIngredients, B, horizontalLabelLoc, C, highlightLabel)

Tool: PointToPixels
PointToPixels(InputPoint,Corner1,Corner3,Corner5)
Input: InputPoint, Corner1, Corner3, Corner5
Output: OutputPixels

xLeft: x(Corner1)
xRight: x(Corner3)
yTop: y(Corner3)
yBottom: y(Corner1)
yPixels: (y(Corner5) * (yTop - y(InputPoint)) / (yTop - yBottom))
xPixels: (x(Corner5) * (x(InputPoint) - xLeft) / (xRight - xLeft))
OutputPixels: (xPixels, yPixels)

Tool: sectorPixels
sectorPixels(Midpoint,B,C,pixelRadius,Corner1,Corner3,Corner5
Input: A, B, C, pixelRadius, Corner1, Corner3, Corner5
Output: newSector

pointRadius: (pixelRadius / x(Corner5) * (x(Corner3) - x(Corner1)))
BPrime: A + (pointRadius * UnitVector[B - A])
newSector = CircleSector(A, BPrime, C)

Tool: onboardingTextOffset
onboardingTextOffset(textCorner1,textCorner3,case,corner1,corner3,corner5)
Input: CornerText1, CornerText3, case, Corner1, Corner3, Corner5
Output: TextOffset

xPixels: ((x(CornerText3) - x(CornerText1)) * x(Corner5) / (x(Corner3) - x(Corner1)))
yPixels: ((y(CornerText3) - y(CornerText1)) * y(Corner5) / (y(Corner3) - y(Corner1)))
xOffset = Element({27, (-xPixels) + 2, 16 - xPixels / 2, 16 - xPixels / 2}, case)
yOffset = Element({-23, -23, yPixels - 27, -49}, case)
TextOffset: (xOffset, yOffset)

Tool: PixelsToPoint
PixelsToPoint(Corner1,Corner3,Corner5,PixelCoords)
Input: Corner1, Corner3, Corner5, InputPixels
Output: OutputPoint

InputPixels: (100, 200)
xRight: x(Corner3)
xLeft: x(Corner1)
yTop: y(Corner3)
yBottom: y(Corner1)
yCoord: yTop - (y(InputPixels) / y(Corner5) * (yTop - yBottom))
xCoord: (x(InputPixels) / x(Corner5) * (xRight - xLeft)) + xLeft
OutputPoint: (xCoord, yCoord)

Tool: expandCircle
expandCircle(A,pixelRadius,Corner1,Corner3,Corner5)
Input: A, pixelRadius, Corner1, Corner3, Corner5
Output: newEllipse

distanceX: (pixelRadius / x(Corner5) * (x(Corner3) - x(Corner1)))
distanceY: (pixelRadius / y(Corner5) * (y(Corner3) - y(Corner1)))
xyScale: distanceY / distanceX
pointGap: distanceX
cMinor = Min(pointGap, (pointGap * xyScale))
cMajor = Max(pointGap, (pointGap * xyScale))
f1: sqrt(cMajor^(2) - cMinor^(2))
A: (3, 4)
newEllipse = If(xyScale < 1, Ellipse[A + (f1, 0), A + ((-f1), 0), A + (cMajor, 0)], Ellipse[A + (0, f1), A + (0, (-f1)), A + (0, cMajor)])