Naked Science Forum
Non Life Sciences => Geek Speak => Topic started by: Dege on 12/01/2009 03:55:34
-
I have been haveing some trouble learning how to write algorithms. can anyone help me?
-
Are you talking maths or computers?
-
computers
-
You have to break it down to single, linear steps. What do you want your algorithm to do?
-
just to predict the next outcome of a numer sequence just somethiing simple like that can you tell me how to do that
-
You have got to be joking! Do you realise how complicated that is? In order to predict the next number you first have to work out what the connection is between the numbers you have to start with.
Can't you start with something simple like an atmospheric model!? [:P]
-
just to predict the next outcome of a number sequence just something simple like that can you tell me how to do that
If the numbers are points on a smooth line it should be possible to extrapolate (http://en.wikipedia.org/wiki/Extrapolation) to the next number.
-
just to predict the next outcome of a number sequence just something simple like that can you tell me how to do that
If the numbers are points on a smooth line it should be possible to extrapolate (http://en.wikipedia.org/wiki/Extrapolation) to the next number.
Certainly, if you are dealing with standard linear relationships. But that assumes that the number sequence consists of numbers that are "related" and dependent. If they are entirely independent, you have no chance. But let's assume that we're dealing with a dependent variable. Curve fitting is rather difficult unless, as Eth says, you already know what the relationship is.
It would be easier to comment if we knew what numbers we were dealing with, and what sort of prediction is required.
-
just to predict the next outcome of a numer sequence just somethiing simple like that can you tell me how to do that
I can however show you where the capital letters are, as well as commas, question marks and full-stops!
(FOG)
-
haha ok sorry guys can yall start me off with just the basics of algorithms and lets work from there
-
Draw a flow diagram (http://en.wikipedia.org/wiki/Functional_flow_block_diagram).
If you told us the intended function we may be able to tell you if it is possible and how complex the programme would have to be,
e.g. if you are looking to create a programme which can predict lottery numbers you're wasting your time.
http://en.wikipedia.org/wiki/Software_development_process
-
no its not for anything like that ok just forget the predictions and just start me off with the simplest thing a algorithm can do, if you dont mind please.
-
Here is a simple flow diagram ...
[ Invalid Attachment ]
-
Haha, very good RD! Top notch!
-
RD - don't start him on iterative loops! [:D]
-
OK thanks allot that helps me out a great deal. OK now one last thing is there any article or download that you know of that can take me through the basics and help me out.thanks again
-
Here is an article...
How to describe software design using diagrams and pseudo-code
http://www.scienceprog.com/how-to-describe-embedded-software-design-using-diagrams-and-pseudo-code/
Pseudo-code (http://en.wikipedia.org/wiki/Pseudocode) is a list of stepwise instructions in plain English, like DoctorBeaver mentioned above, it resembles computer code (a.k.a. computer programme).
-
Don't you ever go to sleep RD?
-
Fibonacci numbers are generated by an algorithm which is easily converted into a computer program.
The first fibonacci numbers are:
0 1 1 2 3 5 8 13 21 34 55
The ninth number is 21, which is the sum of the two previous numbers, 8 + 13.
Likewise, 55 = 34 + 21.
By definition, the first two are 0, 1.
If you want to generate the 100'th fibonacci number, it's easy to say that it is the sum of the 99'th and the 98'th number, but what their value is, being tedious fast.
If you want to generate these numbers in a programming language (there is example fibonacci code for basically every language), you define a function (my example is in python, a programming language):
def fibonacci(n): # Returns the n'th fibonacci number
if n < 2:
return n # The zero'th fibonacci number is 0, the first one is 1, by definition.
else:
return fibonacci(n - 1) + fibonacci(n - 2)
This is quite similar to the explanation in English. If you can describe an algorithm in English (or in math), converting it into a computer-language is quite simple, although you'll have to learn the language first. Describing in English (or in math), what the algorithm does, with all the corner-cases, that's the hard part.
-
OK i would like to thank you all. i am finally starting to get i [:)][img] t. thanks again and i am sorry for the wast of time>