Looking for help with a loop algorithm

Discussion in 'C++' started by Kasterborus, Jan 9, 2008.

  1. Kasterborus

    Kasterborus Guest

    I'm having trouble writing a loop using integer math that will
    spit out 10 numbers and slowly make them all tend to 2048.

    Ideally this loop should take about 400 iterations, and with each pass
    calculate 10 values

    i.e:

    Starting iteration:
    0 455 910 1365 1820 2275 2730 3185 3640 4095

    Ending iteration:
    2048 2048 2048 2048 2048 2048 2048 2048 2048 2048

    (or as close as can be eg.
    2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 ).

    I can successfully make an 11 value sequence work, but 10 is proving
    to be tricky...

    Anyone know how to do this?

    Steve
    Kasterborus, Jan 9, 2008
    #1
    1. Advertising

  2. On 2008-01-09 19:20, Kasterborus wrote:
    > I'm having trouble writing a loop using integer math that will
    > spit out 10 numbers and slowly make them all tend to 2048.
    >
    > Ideally this loop should take about 400 iterations, and with each pass
    > calculate 10 values
    >
    > i.e:
    >
    > Starting iteration:
    > 0 455 910 1365 1820 2275 2730 3185 3640 4095
    >
    > Ending iteration:
    > 2048 2048 2048 2048 2048 2048 2048 2048 2048 2048
    >
    > (or as close as can be eg.
    > 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 ).
    >
    > I can successfully make an 11 value sequence work, but 10 is proving
    > to be tricky...
    >
    > Anyone know how to do this?


    Nope, but those guys over in comp.programming might.

    --
    Erik Wikström
    Erik Wikström, Jan 9, 2008
    #2
    1. Advertising

  3. Kasterborus wrote:
    > I'm having trouble writing a loop using integer math that will
    > spit out 10 numbers


    Split out from where or by what criterion?

    > and slowly make them all tend to 2048.


    What does it mean to "tend to N"? You might want to explain it when
    you repost to the appropriate newsgroup. How "slowly" does it need
    to happen? By steps of 1 or 10 or (2048-N)*0.66667 ?

    > Ideally this loop should take about 400 iterations,


    How do you know?

    > and with each pass
    > calculate 10 values
    >
    > i.e:
    >
    > Starting iteration:
    > 0 455 910 1365 1820 2275 2730 3185 3640 4095
    >
    > Ending iteration:
    > 2048 2048 2048 2048 2048 2048 2048 2048 2048 2048
    >
    > (or as close as can be eg.
    > 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 ).
    >
    > I can successfully make an 11 value sequence work, but 10 is proving
    > to be tricky...


    What's the problem you're seeing? "Proving to be tricky" is not really
    a good description of the problem you're running into.

    > Anyone know how to do this?


    I believe you're in the wrong newsgroup. For help on generic algorithms
    like the one you're seeking, try 'comp.programming'.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Jan 9, 2008
    #3
  4. Kasterborus

    Leclerc Guest

    (loosely connected to your problem)

    you might do a google with ARMAX, ARX, AR, "output error", "Box-Jenkins"
    .....
    Leclerc, Jan 9, 2008
    #4
  5. Kasterborus

    Daniel T. Guest

    Kasterborus <> wrote:

    > I'm having trouble writing a loop using integer math that will
    > spit out 10 numbers and slowly make them all tend to 2048.
    >
    > Ideally this loop should take about 400 iterations, and with each pass
    > calculate 10 values
    >
    > i.e:
    >
    > Starting iteration:
    > 0 455 910 1365 1820 2275 2730 3185 3640 4095
    >
    > Ending iteration:
    > 2048 2048 2048 2048 2048 2048 2048 2048 2048 2048
    >
    > (or as close as can be eg.
    > 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 ).
    >
    > I can successfully make an 11 value sequence work, but 10 is proving
    > to be tricky...


    Care to share the code? Maybe if you do we can show a simple edit that
    will do the trick.
    Daniel T., Jan 9, 2008
    #5
  6. Kasterborus

    Guest

    x-no-archive: yes

    What you are looking for is called a "fixed point" search. This is
    when you apply a function to a guess (which improves the guess),
    and then apply the function to the improved guess.

    As a trivial example of a "fixed point" search, you might average
    your guess with your fixed point and then use the result as an
    improved guess. For example, if I want to converge to the point
    42, then I might use this averaging formula:

    x = (x + 42)/2

    Of course if I want to converge to 2048, I would not use 42, but
    an entirely different value.

    Kasterborus wrote:
    > I'm having trouble writing a loop using integer math that will
    > spit out 10 numbers and slowly make them all tend to 2048.
    >
    > Ideally this loop should take about 400 iterations, and with each pass
    > calculate 10 values
    >
    > i.e:
    >
    > Starting iteration:
    > 0 455 910 1365 1820 2275 2730 3185 3640 4095
    >
    > Ending iteration:
    > 2048 2048 2048 2048 2048 2048 2048 2048 2048 2048
    >
    > (or as close as can be eg.
    > 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 ).
    >
    > I can successfully make an 11 value sequence work, but 10 is proving
    > to be tricky...
    >
    > Anyone know how to do this?
    >
    > Steve
    , Jan 10, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ahmed Moustafa
    Replies:
    0
    Views:
    742
    Ahmed Moustafa
    Nov 15, 2003
  2. Bapaiah Katepalli
    Replies:
    1
    Views:
    1,471
    Mike Treseler
    Jun 23, 2006
  3. addi
    Replies:
    0
    Views:
    255
  4. Andy Baxter

    looking for help with a counting algorithm

    Andy Baxter, Dec 28, 2003, in forum: Perl Misc
    Replies:
    5
    Views:
    84
    Andy Baxter
    Jan 2, 2004
  5. Isaac Won
    Replies:
    9
    Views:
    341
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page