Programming Fractals [closed] - fractals

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Would learning to program fractals help think clearly about certain set of programming problems?

Fractal programming would introduce you to recursion, iteration, graphics programming concepts, image processing, and user interface design. From a mathematics point of view, you would learn about geometry, complex numbers, Mobius transformations (Kleinian fractals), Affine transformation (IFS fractals), root-finding methods (Newton fractals).
And on top of all this, you get the reward of seeing your efforts result in strange and unusual images.

From what I remember you'll get a good handle on recursion if nothing else...maybe a little bitmap level programming as well...

If you are a beginner such activity will surely help you to improve your skills. Apart from that programming fractal visualizations depending on the fractal type and the goal you set may give you some specific skills or knowledge like:
working with graphics, image processing;
understanding recursion and recursive
structures;
optimization techniques;
low-level program optimizations;
understanding how computer operates
(e.g. why resolution would be
normally limited -> floating point
precision and error accumulation);
parallel programming;
some mathematical improvement and
extend your range of interest;
understanding various technologies
(e.g. you can code Mandelbrot
set in PixelBender which is
really fast since may be executed on
GPU);
understanding complex compression
algorithms (e.g. some kind of fractal
compression);
creativity (e.g. you invent your own
fractal set coloring algorithm);
much more else :)
It is indeed a versatile and interesting field, lots of things to explore and learn. I used to draw fractals a lot :)

Fractals got me thinking about complex numbers and branch-points. Whether that was a good thing is, I suppose, a matter of opinion. :-)

Any kind of programming experience is useful. So yes it is.
Especially for:
math problems
basic algorithms
and of course fractal programming

It'll maybe give you practice in implementing mathematical formulae.

Some fractals are good visual examples for explicit recursion; if you have a hard time with that concept, they might be good problems to work. You can start with "turtle graphics" style fractal paths like the Hilbert curve, or the classic "snowflake" fractal.
Many fractal-generation methods use heavy-duty number crunching (e.g., Mandelbrot and Julia sets). Number crunching is of course a field in itself, and tweaking your fractal generator to run as fast as possible can be a nice exercise in optimization.

I don't think programming fractals will teach you anything in particular. Depending on the fractal, I suppose it might teach you a bit about math or fractals in general.
However, I do think fractals are fun as an introduction to programming, and beginners/students are often fascinated by the result, be it more graphic fractals like mandelbrot or julia sets, or more easy to understand L-systems.
Of course, if you're new to programming, it'll also hopefully teach you a lot about programming in general. If nothing else, fractals are interesting to look at.

when I was an undergrad, we used fractal drawing to power our work in parellel processing. It gets fairly computationally intensive quickly, so having multiple CPUs available to do the work lets you see a visible increase in efficiency.
So, along with recursion, I'd say it helps with learning how to balance CPU load across parallel processors.
... or if the equipment isn't available, it probably teaches you Zen-like patience. :)

Great idea! I think coding up fractals makes a great "etude" (study) sized program. It has some nice features this way: generally you won't require much 3rd party code, they can be implemented in a reasonably short amount of time (and complexity) and you get something nice too look at in the end which also verifies your work.
Also there are loads of basic issues in both mathematics and the implementation of numerical algorithms that you will bump into if you do this.
From something as simple as a basic Mandelbrot set generator you can branch out into all sorts of issues as commenters have mentioned. Even sticking with just that, though, you can learn about optimization techniques (why is my generator so slow) and numerical issues (why can't I zoom past here), but also if you want to a bit of color theory (what's Lab* space anyway) and other bits and pieces.
Have fun!

Fractals is a very intellectually interesting topic and well even the simplest implementation will make you learn about complex number maths,graphics generation,scaling images, and general programming.

Related

How to design deep convolutional neural networks? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
As I understand it, all CNNs are quite similar. They all have a convolutional layers followed by pooling and relu layers. Some have specialised layers like FlowNet and Segnet. My doubt is how should we decide how many layers to use and how do we set the kernel size for each layer in the network. I have searched for an answer to this question but I couldn't find a concrete answer. Is the network designed using trial and error or are some specific rules that I am not aware of? If you could please clarify this, I would be very grateful to you.
Short answer: if there are design rules, we haven't discovered them yet.
Note that there are comparable questions in computing. For instance, note that there is only a handful of basic electronic logic units, the gates that drive your manufacturing technology. All computing devices use the same Boolean logic; some have specialised additions, such as photoelectric input or mechanical output.
How do you decide how to design your computing device?
The design depends on the purpose of the CNN. Input characteristics, accuracy, training speed, scoring speed, adaptation, computing resources, ... all of these affect the design. There is no generalized solution, even for a given problem (yet).
For instance, consider the ImageNet classification problem. Note the structural differences between the winners and contenders so far: AlexNet, GoogleNet, ResNet, VGG, etc. If you change inputs (say, to MNIST), then these are overkill. If you change the paradigm, they may be useless. GoogleNet may be a prince of image processing, but it's horrid for translating spoken French to written English. If you want to track a hockey puck in real time on your video screen, forget these implementations entirely.
So far, we're doing this the empirical way: a lot of people try a lot of different things to see what works. We get feelings for what will improve accuracy, or training time, or whatever factor we want to tune. We find what works well with total CPU time, or what we can do in parallel. We change algorithms to take advantage of vector math in lengths that are powers of 2. We change problems slightly and see how the learning adapts elsewhere. We change domains (say, image processing to written text), and start all over -- but with a vague feeling of what might tune a particular bottleneck, once we get down to considering certain types of layers.
Remember, CNNs really haven't been popular for that long, barely 6 years. For the most part, we're still trying to learn what the important questions might be. Welcome to the research team.

Software for solving SDPs

I have been using cvx for doing some experiments with my SDPs. Although it is very easy to use, it is quite slow. I cannot run reasonably large instances in reasonable time. Hence would like someone to point to some faster software.
You can find a list of Semidefinite Programming codes on Hans Mittelmann's Decision Tree for Optimization Software. At least some of the codes are implemented in Matlab (like cvx, right?) or have a Matlab interface.

What's a genetic algorithm that would produce interesting/surprising results and not have a boring/obvious end point?

I find genetic algorithm simulations like this to be incredibly entrancing and I think it'd be fun to make my own. But the problem with most simulations like this is that they're usually just hill climbing to a predictable ideal result that could have been crafted with human guidance pretty easily. An interesting simulation would have countless different solutions that would be significantly different from each other and surprising to the human observing them.
So how would I go about trying to create something like that? Is it even reasonable to expect to achieve what I'm describing? Are there any "standard" simulations (in the sense that the game of life is sort of standardized) that I could draw inspiration from?
Depends on what you mean by interesting. That's a pretty subjective term. I once programmed a graph analyzer for fun. The program would first let you plot any f(x) of your choice and set the bounds. The second step was creating a tree holding the most common binary operators (+-*/) in a random generated function of x. The program would create a pool of such random functions, test how well they fit to the original curve in question, then crossbreed and mutate some of the functions in the pool.
The results were quite cool. A totally weird function would often be a pretty good approximation to the query function. Perhaps not the most useful program, but fun nonetheless.
Well, for starters that genetic algorithm is not doing hill-climbing, otherwise it would get stuck at the first local maxima/minima.
Also, how can you say it doesn't produce surprising results? Look at this vehicle here for example produced around generation 7 for one of the runs I tried. It's a very old model of a bicycle. How can you say that's not a surprising result when it took humans millennia to come up with the same model?
To get interesting emergent behavior (that is unpredictable yet useful) it is probably necessary to give the genetic algorithm an interesting task to learn and not just a simple optimisation problem.
For instance, the Car Builder that you referred to (although quite nice in itself) is just using a fixed road as the fitness function. This makes it easy for the genetic algorithm to find an optimal solution, however if the road would change slightly, that optimal solution may not work anymore because the fitness of a solution may have grown dependent on trivially small details in the landscape and not be robust to changes to it. In real, cars did not evolve on one fixed test road either but on many different roads and terrains. Using an ever changing road as the (dynamic) fitness function, generated by random factors but within certain realistic boundaries for slopes etc. would be a more realistic and useful fitness function.
I think EvoLisa is a GA that produces interesting results. In one sense, the output is predictable, as you are trying to match a known image. On the other hand, the details of the output are pretty cool.

Do you know a good and efficient FFT? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am trying to find a very fast and efficient Fourier transform (FFT). Does anyone know of any good ones. I need to run it on the iPhone so it must not be intensive. Instead, maybe you know of one that is wavelet like, i need frequency resolution but only a narrow band (vocal audio range up to 10khz max...even 10Khz might be too high). Im thinking also of truncating this FFT to keep the frequency resolution while eliminating the unwanted frequency band. This is for an iphone
...I have taken a look at the FFT in Aurio touch but it seems this is an int FFT but my app uses floats.....would it give a big performance increase to try and adapt program to an int FFT or not(which i really dont feel like doing...plus aurio touch uses a radix 2 FFT which is not that great).
The iPhone OS4 SDK will include the Accelerate framework, which will (finally) give us Apple-written FFT functions
Accelerate provides hundreds of
mathematical functions optimized for
iPhone and iPod touch, including
signal-processing routines, fast
Fourier transforms, basic vector and
matrix operations, and
industry-standard functions for
factoring matrices and solving systems
of linear equations.
I've wrapped Ooura's FFT library in Objective-C. Ooura's code is of comparable performance to FFTW, but totally and utterly free.
This code uses double-precision and has several built-in window types (rectangular, Blackwell, Triangle, Hamming). I use Ooura's FFT code to implement Welch's method, which will generate a much smoother spectra when viewed over time.
Check it out at:
http://github.com/alexbw/iPhoneFFT
Give the Fastest Fourier Transform in the West (FFTW) a go, The performance is good compared to others, but it is not completely free. See the details on commercial use here. Obviously being a c library you should have no problem linking it as a static library to your iphone app.
The performance of the FFTW sets the standard for arbitrary length FFT's - especially for non-power of 2 lengths in 2 and greater dimensions. The commercial license for FFTW is $5000, which may or may not fit in your budget.
However, it sounds like you have a 1D signal processing problem in which case you have a few more options - and if you can further either pad or sample your data to power-of-2 lengths, then many libraries will offer reasonable performance. Check out this list of FFT algorithms that FFTW used for comparison - many are free and some may be adequate. I'd probably start with good old numerical recipes which offers an easy power of 2, 1D FFT implementation for free and some typing - and would be very memory efficient.
BTW - for voice you probably only need to go to 3-4Khz....10Khz is way way up there for the
human voice.
Here is a primary source link to Ooura's numerical software:
http://www.kurims.kyoto-u.ac.jp/~ooura/
I have been using many of Ooura's FFTs over the years, I should send him a "domo" at the very least, and I use his real radix-4 in several iPad and iPhone applications under development. I did translate the code to operate with 32-bit single precision for performance on ARM. Looking at the assembly produced with XCode 3.2.2, it vectorizes with NEON SIMD instructions very nicely. I was half disappointed actually, as I was willing to vectorize the code a bit myself for even more performance. These optimizations cannot be had without first translating the FFT to single precision obviously.
While I have used Objective-C for many years, I actively develop using it, and even taught an object oriented programming course using it, I did not prepare such a wrapper (though I had done the same back in 1992 with a different FFT) for performance reasons.
I haven't tested FFTW against Ooura's FFT in at least 10 years, but when I did Ooura's library was faster for 1024 point real FFTs. However, it is quite possible that FFTW may do much better now -- but licensing it and cross-compiling it for ARM is inconvenient and I have always found FFTW to be far too bulky and obtrusive for my DSP needs. Apple's VecLib is very nice but unfortunately they have not ported it to iPhoneOS. I opened a feature request in BugReporter and you can too: https://bugreport.apple.com/
As answered before, the Accelerate Framework now provides some APIs that might help you.
Check:
Accelerate Framework Reference
vDSP Reference
Using Fourier Transforms

What is a fractal? [duplicate]

This question already has answers here:
Closed 14 years ago.
Duplicate of How to program a fractal
What are fractals?
Is this is one of the concepts that is brought over from Mathematics to programming to simplify or solve a particular set of problems?
I am closing this question and have posted a related question
If you want to know about fractals in a general non-programming way, I would suggest looking at a general non-programming site. Wikipedia has a good article on them. If you want to know about programming fractals, I would suggest looking at this already asked question:
How to program a fractal
It even has a fractal tag.
A fractal is generally "a rough or fragmented geometric shape that can be split into parts, each of which is (at least approximately) a reduced-size copy of the whole," a property called self-similarity. The term was coined by BenoƮt Mandelbrot in 1975 and was derived from the Latin fractus meaning "broken" or "fractured." A mathematical fractal is based on an equation that undergoes iteration, a form of feedback based on recursion.
A fractal often has the following features:
It has a fine structure at arbitrarily small scales.
It is too irregular to be easily described in traditional Euclidean geometric language.
It is self-similar (at least approximately or stochastically).
It has a Hausdorff dimension which is greater than its topological dimension (although this requirement is not met by space-filling curves such as the Hilbert curve).
It has a simple and recursive definition.
http://en.wikipedia.org/wiki/Fractal
its a type of self-similar shape, often grounded in a repeated mathematical function (but not necessarily). It has nothing to do with programming technique, but the easiest way to view one is to write a program to draw it. (drawing a fractal with pen-and-paper is pretty time-consuming)
By 'self-similar' i mean, if you keep zooming in on different parts of the fractal, it doesn't get any "smoother" or more linear, as would happen with a non-fractal shape. It's degree of complexity is invariant of the zoom level.
the Wikipedia page is pretty useful
Look up Procedural Generation for one way of how fractals are used in programming. They are an excellent way of generating chaotic/seemingly complex data from a very simple source. The generated data often benefits from self-similarity and other bits of organzation that make the content make more sense to people.