Jump to content

random trigger, with decreasing threshold, "relaxed" to be sparse in time and space


ikoon

Recommended Posts

Let's say, there is a class with 10 children and teacher asks 10 questions with decreasing difficulty. Kids are in a row.

Please, is there any common attitude to make the raised hands sparse in time and space? The total count of raised hands is not crucial. The purpose is just to make it visually appealing.

- first question is the hardest, 1 kid raises hand
- second question, 2 or 3 kids, not the kid from first question, hands are "far away" from each other
- third question, 3 kids who did not answer before, and again gaps between kids
  ...
- tenth question, everybody raises hand
- at the end, each kid raised hand circa 5 times

Edited by ikoon
Link to comment
Share on other sites

The best (and simplest) method I could think of is a brute force:

- generate a number of solutions, with different seed
- for each solution, calculate the "sparsity" with weights (the gap between the answers is more important then the gap between kids)
- choose the solution with the highest sparsity

There are not many kids and questions. I think it is going to be fast. Still, I am curious, if it is a common scripting problem.

Link to comment
Share on other sites

Hi. Here is the crappy function I could think of. It returns list of lists with questions answered by each kid. First question is answered by one kid, last question is answered by everyone.

Kids will get some kind of brain penalty for answers, so they won't know the answer next time. I found if I force this strictly, I get visible switching between two "teams" in the middle.

switching_kids.thumb.png.a491729c9675e063c355191c7d112597.png

 

So, randomized sampling is taking precedence after a few questions:

semirandom_kids.thumb.png.4377fba644911948a46c1a87ab068b28.png

Function returns after everyone answered about X times, 5 for your case.

from random import seed, shuffle, randint
from numpy import median

seed(hou.ch('seed'))

def quiz(num_kids, median_answers, randomness=0.8):
    # Empty lists accumulating answered questions per kid.
    kids = [[] for _ in range(num_kids)]

    # Ask until median amount of answers per kid is met.
    i = 0
    while True:
        # Randomize pending kids to avoid halves switching pattern.
        slice = int(len(kids) * randomness)
        a = kids[:slice]
        b = kids[slice:]
        shuffle(a)
        kids = a + b  # Comment this to see problem.

        # Score approximately i answers.
        pick = randint(max(1, i), min(i + 1, num_kids))
        clever = kids[:pick]
        dumb = kids[pick:]
        clever = [scores + [i] for scores in clever]

        # Extra shuffle for cases where randomness is near 0.
        shuffle(clever)

        kids = dumb + clever

        # Finish if kids answered enough questions.
        if median([len(s) for s in kids]) >= median_answers:
            # Complete last row.
            kids = [s + [i] if i not in s else s for s in kids]
            return kids, i

        i += 1

Close neighbors can still answer simultaneously, though.

 

random_kids.hipnc

  • Thanks 1
Link to comment
Share on other sites

Hi F1! This is great! Thank you very much!

It will take me a while to understand it all, but I really like the solution (add until median per kid is met). This is great idea. Also the shuffle ... I never used that, also the array output is great for me. I can build on that, thank you very very much again!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...