Pseudo-Random numbering

Bobadopolis

No I can't fix it dammit!
Local time
Today, 22:23
Joined
Oct 6, 2005
Messages
77
Hi All,

I am a student (studying Sound and Audio) and will soon be running some listening experiments as part of my course. In this, the listeners listen to 1 of a selection of pieces of audio (possibly 4 in total) and answer questions about it. As I now have some experience in Access it seemed the ideal choice to create the software for these tests (I don't know any other programming languages anyway!). So I've recently got to grips with Windows Media Player ActiveX control so all is going good. Herein lies my problem...

The order that the audio is played in (from listenener to listener) needs to be random to prevent any possible biasing effects resulting from ordering. However, I need to ensure that each excerpt gets an equal number of playings, or that this is kept within tight constraints hence using a standard Random Number generator is not ideal. Ideally, if I had four excerpts I would like it if every four occurences each excerpt occurs once.

I can visualize the process in my head I think (it's not complicated) but I have no idea where to begin programming this.

Thus far my idea is that when the form/software opens it generates said number; each number is associated with an excerpt and a Select Case clause opens that audio file in the WMP ActiveX control. When the user is finished the form would eventually refresh for new data and when it gets there a new number is generated (fitting the above constraints). The form would be bound to the main data table so I can collect responses to questions on the same form.

So... any ideas on how to generate this number? I have searched extensively on this forum and the web but no threads seem to offer quite what I'm after.

Thanks a lot in advance (hope that makes sense!),

Bobadopolis
 
Hi,

Thanks for your response.

Yeah I've been down that route and upon experimentation discovered that the distribution of numbers using the rnd() function is not even as I would like. In my case the required function would be pseudo-random as with the rnd() it is theoretically possible to have 100 1's (for example) in a row.

After 100 trials (for random numbers in the range 1-4) i had 22 Ones, 28 Twos, 28 Threes and 22 Fours. And of course if you reduce the population (as i may well do) the distribution becomes more uneven.

Any suggestions?

Thanks,

Bobadopolis
 
Please help!

Any suggestions anyone?

Bobadopolis
 
Getting there...

Right. I have managed to fudge a way to make the random numbers distribute themselves more evenly. I did this using a crosstab query that counts occurences of each number (1 to 4) and inserted these fields into my form. I then used some vb to force numbers when one number was occuring less than others:

Code:
If Me.txtOne < (Me.txtTwo And Me.txtThree And Me.txtFour) Then
    Me.txtRandomNo.Value = 1
Else
    If Me.txtTwo < (Me.txtOne And Me.txtThree And Me.txtFour) Then
        Me.txtRandomNo.Value = 2
    Else
        If Me.txtThree < (Me.txtOne And Me.txtTwo And Me.txtFour) Then
            Me.txtRandomNo.Value = 3
        Else
            If Me.txtFour < (Me.txtOne And Me.txtTwo And Me.txtThree) Then
                Me.txtRandomNo.Value = 4
            Else
                Randomize
                Me.txtRandomNo.Value = CInt(Int((4 - 1 + 1) * Rnd() + 1))
            End If
        End If
    End If
End If

It's not ideal but it works! The next hurdle however seems the biggest - how to force the 'random' number to not be the same as the previous!

Any ideas anyone? What do you think to my current method?

Cheers,

Bobadopolis
 

Users who are viewing this thread

Back
Top Bottom