In the screen capture below, the first form of the ode has a composite function y(x(t)), I would like to solve for this function y(x(t)), which dsolve can't do. If I re-write the equation in the form of x(t), without the composition dsolve works fine. Is there a clean way to get this to solve without re-writing the equation?
screen capture
I'm new at sympy and I've been fumbling around with no success....
Related
I have been trying to find a algorithm to strongly solve the game Teeko. The game is played on a 5x5 board were each player has 4 pieces and attempts align them in any direction or create a square out of them. (assume there is no drop phase)
I have tried solving the game by using a negamax with alpha beta pruning and other optimizations like a transposition table but that has not seemed to have worked because the solver would usually get stuck in loops were neither player wants to deviate from there strategy as it would result in them loosing. From my research I have found stuff like Nash Equilibrium as a potential solution but I cant figure out how to implement it. Furthermore, I have found that the game has been solved and found that the with prefect play it result in a draw previously: https://pcarrier.com/teeko/text/teeko.results.txt
Are there any algorithms that might be able to give the same result as minimax and hanlde repeating positions and how could I implement it and are there any other algorithms that give the same result as minimax?
Minimax (or Negamax) is well capable of handling repeating positions using transposition tables, as you mention in your question. Transposition tables are complicated to implement though so maybe you have a bug?
The problem with minimax is that you either:
NEed to solve it until the game is completed to get a score. This is possible for simple games like tic-tac-toe, but not for more complicated games like chess.
Score each node using some heuristic function, which is the case for e.g. chess.
I am not sure about Teeko, is it possible to get to all leaf nodes with minimax and alpha beta pruning? Could you do other things to reduce the search tree, like transpotision tables or other cut offs? If so then minimax is a great option.
Is it possible to create some kind of evaluation function for this game? It seems hard to me, but maybe that is because I know too little about the game. Is it better to have central squares? Better to get 2 in a row than to spread out pieces? Evaluation function is something you could have a look at if you are a good player of the game, or find good sources online.
I'm experimenting with ELKI (which is awesome, btw) and would like to try the weighted Euclidean distance function as a metric for the DBSCAN algorithm.
First of all, I don't know how it works, except for this.
I tried a few values for the parameter distance.weights. If I insert for example 3,1 in its field, this is what I get after I hit ENTER:
I'm still able to run the task but I see no difference in the results, no matter the values I insert.
Could anyone please provide a short explanation on how the function works and eventually what I'm doing wrong?
Thanks in advance.
I'm doing Spline interpolation in C++. I've used code from here: http://tehc0dez.blogspot.ch/2010/04/nice-curves-catmullrom-spline-in-c.html (the code is also linked on that page, it's up on github). The app is working just fine for closed contours, since it's copying the first three points to the end.
But in my case I need to be able to make an "open" shape - or rather line-, where the first and last points are not connected.
It is my understanding that since the Catmull-Rom spline is cubic, I won't be able to calculate the interpolated points for the first and last segment without adding any additional points.
I read that a common method to interpolate the points in those two segments is to use Quadratic Interpolation.
Unfortunately I can't wrap my head around how to do this. I've found out how to do quadratic Bezier approximation, but this is not what I want to do since I don't want to introduce any additional support points.
I found this site: http://dafeda.wordpress.com/2010/09/01/newtons-divided-difference-polynomial-quadratic-interpolation/ Which explains quite nicely how to do Quadratic interpolation. But I don't know how to adapt this for my case, where I want to calculate a new Point rather than just y.
Any help would be appreciated. Thanks !
The usual way to do this is to add a second copy of your two end points... So if you have a spline passing through A-B-C-D then you will calculate the spline A-A-B-C-D-D.
Managed to implement a decent solution thanks to the formula found here: http://www.doc.ic.ac.uk/~dfg/AndysSplineTutorial/Parametrics.html
They also provide a nice Java applet to check out the different parameters.
For my problem I set the t1 value to 0.5 and check if t is above/below this threshold, since I only want to draw one segment of the curve! Works out nicely.
I've developed a little program that let me load an image then make some angle measurements onto it. Here is a screenshot (there is no image loaded in this screenshot).
When all the measurements are done I have a list of x, y and angle values. What I'd like to do is interpolate them to generate some kind of graph.
I would prefer to directly implement this functionality and not rely on any other library (as long as it's possible and not to complicated).
So basically I see two steps, first interpolating the data, second, generating a graph from it.
At first I was going to implement some bicubic interpolation but this kind of interpolation needs a regular grid, which I can't ensure.
For the moment I think I have to main options:
Convert my data to a regular grid and then do a bicubic interpolation.
Find an other kind of interpolation that doesn't require a regular grid.
What way do you think I should go and do you have any idea of which grid-redefining/interpolation I should use? I don't have any opinion on both methods but I think this is going to take me a lot of time and I wouldn't like to realize in the end that I am in a dead-end.
If this is of any relevance I'm working with Qt and on windows.
Edit: Basically I want something like that in the end:
What you are looking for is a 2D Least squares fitting function, and generating a heat map or a 3D surface.
QWT is nice library that can help with graphing it, but it is doable without it.
Google Least Squares 2D Calculation
I'm using Kinect with OpenNI/NITE. OpenNI can track human hands with the assistance of NITE. Also, OpenNI can smooth the tracked hand line, and I was trying to figure out how it does that.
I tried using Kalman filters, replaced the old hand position with the kalman estimated hand position, but still the smoother in OpenNI is much better.
I'd appreciate any clues on how to smooth online data or how to set the parameters in a Kalman filter (something specific to hand tracking, since I already know what the parameters do).
Using Kalman filter is not as easy as it seems. You need to choose a good motion model, a good state vector and a good measurement model. For your problem, as I guess you do 3d tracking of position, not orientation (x,y and z position of the hands on the screen) I would choose the following:
State vector =[x, y, z, v_x, v_y, v_z]
Update equations: (x,y,z) = (x,y,z)+ (v_x,v_y,v_z)*delta(t)
velocity would be constant
You also need to set the covariance of error properly, as this will model the error of choosing velocity to be constant (which is not true).
Check this paper. Have a look to the Jacobians needed for the predict and update equations of the filter. They are important. If you consider them identity, the filter will work, but it will only work with accuracy if you choose properly the Jacobians W (multiplies Q), H and A. Q and R are diagonal, try to give values experimentaly.
Hope this helps, good luck.
Here There is a simple example that shows how to set parameters of a kalman filter.
Thee example represents a simple way to test the different smoothed output visually. Checking the comments also helped me to understand the different parameters (noise, motion model, initialization, etc).
Hope it helps, it works quite well, and the code is simple to understand.
It uses the opencv implementation.
Hope it helps!