473,385 Members | 1,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Looking for help with a loop algorithm

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 9 '08 #1
5 1704
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
Jan 9 '08 #2
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
Jan 9 '08 #3
(loosely connected to your problem)

you might do a google with ARMAX, ARX, AR, "output error", "Box-Jenkins"
.....
Jan 9 '08 #4
Kasterborus <ka*********@yahoo.comwrote:
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.
Jan 9 '08 #5
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 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like...
8
by: Ben Fidge | last post by:
I have a requirement to compare two lists, generating a third which is a combination of both. With the first list as the reference list and the second as the test list, I want the each of the...
9
by: kwindham | last post by:
This program doesn't seem like it should be too hard, but I cannot figure it out. Here is the assignment: Password Verifier - Write a program to verify passwords, satisfying the following...
10
by: Nemok | last post by:
Hi, I am trying to write an additive encryption algorithm in C++ that will encrypt a text by adding a random numer to each character in a string. The code looks similar to this: for(int...
6
by: samuel.y.l.cheung | last post by:
Hi, I am trying to convert a Java iterator loop to C++ STL? the loop looks like this: public static boolean func (List aList) { int minX = 0 for (Iterator iter = aList.listIterator(1);...
17
by: Allerdyce.John | last post by:
Hi, I am trying to compare the amount of work between using STL algorithm VS a plain Java loop. Let's say the class Rect has 2 attributes: area, and areaPerCent. In Java, I just write a...
4
by: eking | last post by:
//Thanks for any help,thank you!лл¡£ public override void FloodFill(Bitmap bmp, Point pt) { int ctr=timeGetTime(); //Debug.WriteLine("*******Flood Fill******"); //get the color's int...
1
by: al2004 | last post by:
Write a program that reads information about youth soccer teams from a file, calculates the average score for each team and prints the averages in a neatly formatted table along with the team name....
5
by: quakersquares | last post by:
As part of a program I have to multiply two long numbers out, numbers that dont fit in any int. I feel that I have the algorithm right, but somehow the code just isnt working out and I cannot see...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.