Is the Fibonacci lattice the very best way to evenly distribute N points on a sphere? So far it seems that it is the best - fibonacci

Over in the thread "Evenly distributing n points on a sphere" this topic is touched upon:
Evenly distributing n points on a sphere.
But what I would like to know is: "Is the Fibonacci lattice the very best way to evenly distribute N points on a sphere? So far it seems that it is the best. Does anyone know of a better method?"
I have a Ph.D. in physics and may have an application for some of this research in physics.
I came across this wonderful paper:
http://arxiv.org/pdf/0912.4540.pdf "Measurement of areas on a sphere using
Fibonacci and latitude–longitude lattices"
The paper states, "The Fibonacci lattice is a particularly appealing alternative [15, 16, 17, 23, 65, 42, 66, 67, 68, 76, 52, 28, 56, 55]. Being easy to construct, it can have any odd number of points [68], and these are evenly distributed (Fig. 1) with each point representing almost the same area. For the numerical integration of continuous functions on a sphere, it has distinct advantages over other lattices [28, 56]."
It the Fibonacci lattice the very best way to distribute N points on a sphere so that they are evenly distributed? Is there any way that is better?
As seen above, the paper states, "with each point representing almost the same area. "
Is it impossible, in principle (except for special rare cases of N such as 4, etc.), to exactly evenly distribute N points on a sphere so that each point/region has the exact same area?
So far it seems to me that the Fibonacci lattice the very best way to distribute N points on a sphere so that they are evenly distributed. Do you feel this to be correct?
Thanks so much!

Related

Finding keypoints in an handwritten arrow

I have been trying to find two keypoints (head and tail) in arrows I have drawn,
I was wondering is there a simpler approach than training a CNN, such as a using a classic approach (opencv).
I have used this simple approach:
bi = cv2.bilateralFilter(gray, 5, 75, 75)
dst = cv2.cornerHarris(bi, 2, 3, 0.02)
Here are the images, before:
After some simple image processing I get:
I could pick the two red dots with the longest euclidean distance (checking all combinations of pairs), but sadly for the self loop case it won't give me the correct result. can someone suggest me a better approach?
Any suggestion is highly appreciated, thank you all!
The image is quasi-binary. Consider binarization followed by thinning. You can find the tips and junctions. You can also follow the arcs.

Is kmeans repeatable?

I wanted to know if we get roughly the same centroid points for the exact same data set given that the initial centroid points are chosen randomly.
I'm writing a test kmeans program, and they don't seem to match. I wanted to know if what I'm doing is right.
The k-means algorithm requires some initialization of the centroid positions. For most algorithms, these centroids are randomly initialized with some method such as the Forgy method or random partitioning, which means that repeated iterations of the algorithm can converge to vastly different results.
Remember that k-means is iterative, and at each "move centroid" step, each centroid is moved to a position that minimizes its distance from its constituent points. This makes it heavily dependent on the starting position.
Because of this, it's usually advisable to run k-means several times, and select the clustering that minimizes the error.
No it is not guaranteed.
Consider a simple case of 2-means with 4 points: (1, 1), (-1, 1), (1, -1), (-1, -1) (a square in a 2D plane)
then the 2 centroids may be {(0, 1), (0, -1)} or {(1, 0), (-1, 0)}, two very different results.
Many k-means implementations allow fixing the random number generator to make results reproducible.
ELKI: -kmeans.seed parameter
Weka: -s parameter
In others, you can usually provide the initial centers yourself, and then use reproducible pseudo-random seeding to choose them yourself.

Ideal Input In Neural Network For The Game Checkers

I'm designing a feed forward neural network learning how to play the game checkers.
For the input, the board has to be given and the output should give the probability of winning versus losing. But what is the ideal transformation of the checkers board to a row of numbers for input? There are 32 possible squares and 5 different possibilities (king or piece of white or black player and free position) on each square. If I provide an input unit for each possible value for each square, it will be 32 * 5. Another option is that:
Free Position: 0 0
Piece of white: 0 0.5 && King Piece of white: 0 1
Piece of black: 0.5 1 && King Piece of black: 1 0
In this case, the input length will be just 64, but I'm not sure which one will give a better result. Could anyone give any insight on this?
In case anyone is still interested in this topic—I suggest encoding the Checkers board with a 32 dimensional vector. I recently trained a CNN on an expert Checkers database and was able to acheive a suprisingly high level of play with no search, somewhat similar (I suspect) to the supervised learning step that Deepmind used to pretrain AlphaGo. I represented my input as an 8x4 grid, with entries in the set [-3, -1, 0, 1, 3] corresponding to an opposing king, opposing checker, empty, own checker, own king, repsectively. Thus, rather than encoding the board with a 160 dimensional vector where each dimension corresponds to a location-piece combination, the input space can be reduced to a 32-dimensional vector where each board location is represented by a unique dimension, and the piece at that location is encoded by a set of real numbers—this is done without any loss of information.
The more interesting question, at least in my mind, is which output encoding is most conducive for learning. One option is to encode it in the same way as the input. I would advise against this having found that simplifying the output encoding to a location (of the piece to move) and a direction (along which to move said piece) is much more advantageous for learning. While the reasons for this are likely more subtle, I suspect it is due to the enormous state space of checkers (something like 50^20 board possitions). Considering that the goal of our predictive model is to accept an input containing an enourmous number of possible states, and produce one ouput (i.e., move) from (at-most) 48 possibilities (12 pieces times 4 possible directions excluding jumps), a top priority in architecting a neural network should be matching the complexity of its input and output space to that of the actual game. With this in mind, I chose to encode the ouput as a 32 x 4 matrix, with each row representing a board location, and each column representing a direction. During training I simply unraveled this into a 128 dimensional, one-hot encoded vector (using argmax of softmax activations). Note that this output encoding lends itself to many invalid moves for a given board (e.g., moves off the board from edges and corners, moves to occupied locations, etc..)—we hope that the neural network can learn valid play given a large enough training set. I found that the CNN did a remarkable job at learning valid moves.
I’ve written more about this project at http://www.chrislarson.io/checkers-p1.
I've done this sort of thing with Tic-Tac-Toe. There are several ways to represent this. One of the most common for TTT is have input and output that represent the entire size of the board. In TTT this becomes 9 x hidden x 9. Input of -1 for X, 0 for none, 1 for O. Then the input to the neural network is the current state of the board. The output is the desired move. Whatever output neuron has the highest activation is going to be the move.
Propagation training will not work too well here because you will not have a finite training set. Something like Simulated Annealing, PSO, or anything with a score function would be ideal. Pitting the networks against each other for the scoring function would be great.
This worked somewhat well for TTT. I am not sure how it would work for Checkers. Chess would likely destroy it. For Go it would likely be useless.
The problem is that the neural network will learn patters only at fixed location. For example jumping an opponent in the top-left corner would be a totally different situation than jumping someone in the bottom left corner. These would have to be learned separately.
Perhaps better is to represent the exact state of the board in position independent way. This would require some thought. For instance you might communicate what "jump" opportunities exist. What move-towards king square opportunity's exist, etc and allow the net to learn to prioritize these.
I've tried all possibilities and intuitive i can say that the most great idea is separating all possibilities for all squares. Thus, concrete:
0 0 0: free
1 0 0: white piece
0 0 1: black piece
1 1 0: white king
0 1 1: black king
It is also possible to enhance other parameters about the situation of the game like the amount of pieces under threat or amount of possibilities to jump.
Please see this thesis
Blondie24 page 46, there is description of input for neural network.

when will KD tree search for KNN not work?

I've been exploring and learning about KD Trees for KNN (K Nearest Neighbors problem)
when would the search not work? or would be worth or not improve the naive search.
are there any drawbacks of this approach?
K-d trees don't work too well in high dimensions (where you have to visit lots and lots of tree branches). One rule of thumb is that if your data dimensionality is k, a k-d tree is only going to be any good if you have many more than 2^k data points.
In high dimensions, you'll generally want to switch to approximate nearest-neighbor searches instead. If you haven't run across it already, FLANN ( github ) is a very useful library for this (with C, C++, python, and matlab APIs); it has good implementations of k-d trees, brute-force search, and several approximate techniques, and it helps you automatically tune their parameters and switch between them easily.
It depends on your distance function.
You can't use k-d-trees with arbitrary distance functions. Minkowski norms should be fine though. But in a lot of applications, you will want to use more advanced distance functions.
Plus, with increasing dimensionality, k-d-trees work much less good.
The reason is simple: k-d-trees avoid looking at points where the one-dimensional distance to the boundary is already larger than the desired threshold, i.e. where for Euclidean distances (where z is the nearest border, y the closes known point):
(x_j - z_j) <=> sqrt(sum_i((x_i - y_i)^2))
equivalently, but cheaper:
(x_j - z_j)^2 <=> sum_i((x_i - y_i)^2)
You can imagine that the chance of this pruning rule holding decrease drastically with the number of dimensions. If you have 100 dimensions, there is next to no chance that a single dimensions squared difference will be larger than the sum of squared differences.
Time complexity for knn :O(k * lg(n))
where k is k-nearest neighbours and lg(n) is kd-tree height
kd-trees will not work well if the dimensions of the data set is high because of such huge space.
lets consider you have many points around the origin ,for simplicity consider in 2-D
If you want to find k-nearest neighbours for any point ,then you have to search along 4 axes because all points are closer to each other which results in backtracking to other axis in kd-tree,
So for a 3-dimensional space we have to search along 8 directions
To generalize for n -dimensional it is 2^k
So the time-complexity becomes O(2^k * lg(n))

Need heuristic function for Reversi(Othello) ideas

I have just studied about heuristic functions but I cant find an idea for heuristic function for reversi(Othello), I just need a good idea for grading some state of the board
I thought about :
count the number of moves
count the number of discs
and count the number of discs that are in corner and give them better score,
I dont know if it is good.
No, it is not good enough. The number of disks is particularly useless - although it is the goal of the game to collect as many as possible, the count on any move except for the last one is rather meaningless. Here are a few more things that you should take into consideration:
Counting the number of moves gives you a measure of immediate mobility; everything else being equal, situations when you can make a move that opens up more other moves should be favored. You need to measure the potential mobility as well - the number of opponent's disks next to an open space.
X squares - B2, B7, G2, and G7. Placing your disk there early almost certainly gives away the adjacent corner, so your heuristic should give them high negative weight, at least in the first 40 moves
C squares - A2, A7, B1, G1, H2, H7, B8, and G8. They offer the opponent access to corners, so their value should be different from that of other squares, at least when the edge has fewer than five disks
You can read a relatively short description of the strategy used in building a relatively strong (in the sense of its ability to beat human novices) reversi applet here.
A good heuristic function for othello/reversi needs to capture more aspects of the positions, including:
Coin parity
Mobility (No. of possible moves)
Corner captivity (corners are stable/cannot be turned and have special importance)
Stability (measure of discs being immune from being turned)
I've discussed these aspects and provided implementation of a good heuristic function here: http://kartikkukreja.wordpress.com/2013/03/30/heuristic-function-for-reversiothello/
You could try it. Nothing like data for getting an answer.
Assuming you use reasonable software engineering practice and abstract the heuristic, you could check it pretty quickly.

Resources