Use Sampler to model conditional probability

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #15763 Score: 0
    Lee Creighton
    Participant

    I got asked to solve the following problem from an IB Analysis teacher. (I’ve left it in the original British English, sorry):

    A box of colouring pens contains five pens that are broken and nine pens that work. Two children, a boy and a girl, each take a pen. If exactly one broken pen is chosen, what is the probability that the girl chose it?

    I analytically solved the problem and got the answer ½, but I’d like to create a simulation in CODAP using the Sampler. It’s easy to set up the situation with the fourteen pens, it’s easy to pick two at a time, and it’s easy to use a formula to assign one choice to a girl and one to a boy. What I can’t figure out is how to determine if the situation described in the problem—exactly one broken pen is chosen—is satisfied.

    I’m attaching the shareable link to my setup and attaching the .codap file. Any ideas appreciated!

    https://codap.concord.org/app/static/dg/en/cert/index.html#shared=https%3A%2F%2Fcfm-shared.concord.org%2FV55Fr92swTYOzrlnk9cS%2Ffile.json

    #15771
    Dan Damelin
    Keymaster

    Here is one way to do that. There is a new attribute which counts the “broken” pens drawn, and if equal to 1, then finds the gender of the person who has the broken pen, otherwise the value is “”.

    https://codap.concord.org/app/static/dg/en/cert/index.html#shared=https%3A%2F%2Fcfm-shared.concord.org%2FsX3ZEQerOJ2wbwVclbVA%2Ffile.json

    #15772
    Lee Creighton
    Participant

    I think we were on the same track. I gave this more work today before seeing your answer, and have it here:

    https://codap.concord.org/app/static/dg/en/cert/index.html#shared=https%3A%2F%2Fcfm-shared.concord.org%2FXMZyLuacWYQkoMokVwd4%2Ffile.json

    Essentially, I used two samplers: one to generate random draws of two pens, and another to select the genders (without replacement, so I got one boy and one girl in random order). This felt like the natural way to gether samples. (I didn’t know that I could use count(output, output=filter)like you did—neato.)

    I then made a new column in the samples table to count how many broken pens there were in each sample. And I got stuck there.

    Do you think there’s a way to proceed with my setup? I tried using a histogram to only select those where there was only one broken pen, but I saw no way to check if the pen was assigned to a girl. I made a 2×2 graph showing boy/girl and broken/not broken with only the (broken count==1) points, but if I added more rows to the table, I had to manually go back and re-select only the (broken count==1) rows again. Plus, the 2×2 graph shows double information.

    #15773
    Lee Creighton
    Participant

    I really want to edit my response, but I guess I’m in the content approval bin. It doesn’t show up for me.

    #15786
    Dan Damelin
    Keymaster

    I don’t think there is a graph you could make in v2 that would automatically update without adding a new attribute that uses the count to fill in the value as the gender label or nothing. There is also a new view filtering option in v3 that would make this possible without adding the new gender attribute or even without adding any new attributes to the Sampler table. In CODAP v3, there is a new option in the “view” menu on a graph to filter the graph view by some expression. This doc demonstrates all three methods: https://codap.concord.org/beta#shared=https%3A%2F%2Fcfm-shared.concord.org%2FNwtXqC6C016qwRsp97Uc%2Ffile.json

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.