Shop OBEX P1 Docs P2 Docs Learn Events
AW: AW: AW: AW: [basicstamps] Re: Tricky Random Question — Parallax Forums

AW: AW: AW: AW: [basicstamps] Re: Tricky Random Question

ArchiverArchiver Posts: 46,084
edited 2002-06-20 19:43 in General Discussion
Hey Tracy,

thanx for the neat little random-programs. I think the second one is
slightly above my horizon because the 'shifter' requires deeper
understanding of boolean operations. I know what an xor operation is in
principle but that is not enough to really see what you are doing there...

What I like most about the first program is that it is very simple but does
exactly what I wanted in the first place. The 'cheap trick' of picking them
up one by one, find a random second one and then just swap them was exactly
what I was looking for but I couldnot put my finger on it.
The elegant thing about it is that you get complete random in a defined time
for the price of the chance to replace some elements more than once which is
no price at all because it makes it even more random. To put it the other
way round: my own solution would have taken unpredictable time because I
would have to wait until random has 'found' every element of my list.

One more question: why couldn't I take a regular BS2 and use READ and WRITE?

Thanks again for your help and have a nice day,

Uli



Urspr

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-06-20 19:07
    >Hey Tracy,
    >
    >thanx for the neat little random-programs. I think the second one is
    >slightly above my horizon because the 'shifter' requires deeper
    >understanding of boolean operations. I know what an xor operation is in
    >principle but that is not enough to really see what you are doing there...

    My own first encounter with the "shifter" and its randomness was in a
    biological context, but one very different from the one Dennis
    described. In "chaos theory". Imagine an insect that is born, then
    after a fixed number of days it lays eggs, and then, after a few more
    days, more eggs, and so on until end of life. All those eggs went
    back to the beginning of the "conveyer belt" of life. The total
    number of insects on the "conveyer belt" built up and fluctuated
    wildly, depending on the ages points for egg laying. There was also
    a limited food supply that determined fecundity, so after a while the
    population would build to large numbers and then crash. We also used
    more realistic dynamic models where the timing was not fixed, and
    those too could be "chaotic".


    >What I like most about the first program is that it is very simple but does
    >exactly what I wanted in the first place. The 'cheap trick' of picking them
    >up one by one, find a random second one and then just swap them was exactly
    >what I was looking for but I couldnot put my finger on it.
    >The elegant thing about it is that you get complete random in a defined time
    >for the price of the chance to replace some elements more than once which is
    >no price at all because it makes it even more random. To put it the other
    >way round: my own solution would have taken unpredictable time because I
    >would have to wait until random has 'found' every element of my list.
    >
    >One more question: why couldn't I take a regular BS2 and use READ and WRITE?

    You could, but remember that the eeprom would wear out after some
    large number of times, say one million. So if you only need to
    execute this program 1000 times, it should not be a problem. There
    are also tricks you can program in, to spread the wear out, by
    changing the 90 bytes you use for the table from time to time.

    >
    >Thanks again for your help and have a nice day,
    >
    >Uli


    Good luck with the project. Is it part of a public exhibit or something?

    Tracy
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-20 19:43
    > >One more question: why couldn't I take a regular BS2 and use READ and WRITE?
    >
    >You could, but remember that the eeprom would wear out after some
    >large number of times, say one million. So if you only need to
    >execute this program 1000 times, it should not be a problem. There
    >are also tricks you can program in, to spread the wear out, by
    >changing the 90 bytes you use for the table from time to time.

    Also, it will be quite slow in comparison to using scratchpad RAM.
    Each WRITE takes about 3 milliseconds, so doing that 180 times for
    each shuffle would take over 0.5 second. Compared to about .05
    second using PUT.

    -- Tracy
Sign In or Register to comment.