Overbryd
Overbryd

Reputation: 5006

How to translate a mathematically described algorithm to a programming language?

Given an algorithm, described in a paper of your choice with a bunch of symbols and a very special notation. How do I learn to read such algorithm descriptions and turn them into a computer program?

The following picture describes an algorithm to calculate the incremental local outlier factor:

incremental LOF

What is the best approach to translate that to a programming language?

Your answer can also help me by pointing to articles that describe the symbols being used, the notation in general and tutorials on how to read and understand such papers.

Upvotes: 2

Views: 2813

Answers (3)

Anderson Green
Anderson Green

Reputation: 31840

I have written a translator that is able to convert some simple mathematical formulas into various programming languages. This is the input in in mathematical notation:

distance_formula(x1,y1,x2,y2) = sqrt((x1-x2)^2+(y1-y2)^2)

and this is the output in Python:

def distance_formula(x1,y1,x2,y2):
    return math.sqrt(((x1-x2)**2)+((y1-y2)**2))

Similarly, there are several pseudocode translators that have been designed to convert descriptions of algorithms into equivalent programs.

Upvotes: 0

Edward
Edward

Reputation: 7100

You seem to be asking for what is generally described as part of a course in first-order predicate calculus. A general introduction (including notation) can be found here or in your library.

Generally, notation like enter image description here means "for all enter image description here that are in the set enter image description here..." and would often be implemented in programming language using a for loop or similar looping structure, depending on the particular language.

Introductory books on algorithms will also likely be useful in answering the questions you have. An example would be Sedgewick's book Algorithms in C if your target computer language is C.

Upvotes: 1

Codor
Codor

Reputation: 17605

I think the question can only be answered in a very broad sense. The pseudocode notation in algorithmic papers does not follow a consistent standard, and sometimes no pseudocode notation for the algorithms in question. A general advice would be to study the problem covered as much as possible and to get into mathematics a bit.

Upvotes: 0

Related Questions