Here are three curve
All the curve contains so many spikes and noises. I'm interesting to see which curve has less chaos
One way is to use np.convolve to smooth the curve. Unfortunately, it lost so much information and defeat my original purposes.
I'm wondering if there different way of visualization ? (Not necessarily plotting the curve but use some math theorem to visualize the chaos in a different way)
Maybe Flatten out your plot by specifying the width, height for you plot.
Related
I am a civil engineering grad student working on survival modeling of bridges. I am using SAS with Kaplan-Meier method to analyze the data. I would like to overlay the survival probability plot with a smooth curve using either Kernel smoothing or Bezier smoothing. But since these methods are not available in statistic packages, I exported the survival probability to an excel in order to produce it manually (I may be wrong on doing this). After several attempt I could not figure out on how to do it in Excel.
I am attaching an excel file image with data and the Kaplan Meier curve I am working and would be grateful if someone could help me by coding either the kernel smoothing or Bezier smoothing steps and overlay the curve and repost the file here to me. Or, more effeciently provide me with an excel add in to do this or a SAS code to do this.
If a parametric model providing a smoothed description of the survival data isn't appropriate, you could use smoothing splines or loess curves, compared on this page for example. For smoothing, multiple Bézier curves are combined to form one type of spline, and loess is one form of a kernel smoother. These are easily implemented in standard statistical software packages; for example, in SAS TRANSREG provides splines and LOESS implements that locally-weighted regression.*
That said, baseline survival curves in clinical studies are typically presented as the type of step function that you display, without smoothing. Also, it seems that your underlying data might only provide information at 1-year intervals. If so, then presenting a smooth curve might be somewhat misrepresenting the smoothness of your data. If you do have individual event and censoring times for each bridge, then your smoothed curve should be based on the survival probabilities at each event time to provide the closest representation of your data.
*I would be wary of using Excel for any serious statistical work. I have found it too easy to make unforced errors that avoid detection in Excel.
I have historical aircraft trajectory data with points varying from 1 second - 1 minute separation. Often these points present sharp turns. I'm looking for suggestions of best methods of resampling the data to generate smooth paths (e.g. point every n seconds) that more realistically represent the path followed. It would be useful to be able to parameterize the function with certain performance characteristics (e.g. rate of change of direction).
I'm aware of algorithms like the Kalman filter, Bezier curve fitting, splines etc. for data smoothing. But what algorithms would you suggest exploring as a starting point for generating smooth turns?
Schneider's Algorithm is an algorithm that approximately fits curves through a series of points.
The resulting curves have a drastically reduced point-count and it's error-tolerance is configurable, so you can adjust it as much as you need to.
In general:
Lower error-tolerance: More points, more accurate, less execution
Higher error-tolerance: Less points, less accurate, faster execution
Some useful links:
A live Javascript example, and it's implementation here.
Python Example
C++ implementation
If the resulting curve must pass exactly through your points, you need an interpolation algorithm instead of an approximation algorithm, but keep in mind that those do not reduce point-count.
A really good type of interpolating spline is the Centripetal Catmull-Rom Spline.
I figured someone probably asked this question before but I wasn't able to find an answer.
I'm writing a physics library for my game engine (2d, currently in actionscript3, but easily translatable to C based languages).
I'm having problems finding a good formula to calculate the inertia of my game objects.
The thing is, there are plenty of proven formulas to calculate inertia around a centroid of a convex polygon, but my structure is slightly different: I have game-objects with their own local space. You can add convex shapes such as circles and convex polygons to this local space to form complex objects. The shapes themselves again have their own local space. So there are three layers: World, object & shape space.
I would have no problems calculating the inertia of each individual polygon in the shape with the formulas provided on the moments of inertia Wikipedia article.
or the ones provided in an awesome collision detection & response article.
But I'm wondering how to relate this to my object structure, do I simply add all the inertia's of the shapes of the object? That's what another writer uses to calculate the inertia of triangulated polygons, he adds all the moments of inertia of the triangles. Or is there more to it?
I find this whole inertia concept quite difficult to understand as I don't have a strong physics background. So if anyone could provide me with an answer, preferably with the logic behind inertia around a given centroid, I would be very thankful. I actually study I.T. - Game development at my university, but to my great frustration none of the teachers in their ranks are experienced in the area of physics.
Laurens, the physics is much simpler if you stay in two dimensional space. In 2D space, rotations are described by a scalar, resistance to rotation (moment of inertia) is described by a scalar, and rotations are additive and commutative. Things get hairy (much, much hairier) in three dimensional space.
When you connect two objects, the combined object has its own center of mass. To calculate the moment of inertia of this combined object, you need to sum the moments of inertia of the individual objects and also add on offset term given by the Steiner parallel axis theorem for each individual object. This offset term is the mass of the object times the square of the distance to the composite center of mass.
The primary reason you need to know the moment of inertia is so that you can simulate the response to torques that act on your object. This is fairly straightforward in 2D physics. Rotational behavior is an analog to Newton's second law. Instead of F=ma you use T=Iα. (Things once again are much hairier in 3D space.) You need to find the external forces and torques, solve for linear acceleration and rotational acceleration, and then integrate numerically.
A good beginner's book on game physics is probably in order. You can find a list of recommended texts in this question at the gamedev sister site.
For linear motion you can just add them. Inertia is proportional to mass. Adding the masses of your objects and calculating the inertia of the sum is equivalent to adding their individual inertias.
For rotation it gets more complicated, you need to find the centre of mass.
Read up on Newton's laws of motion. You'll need to understand them if you're writing a physics engine. The laws themselves are very short but understanding them requires more context so google around.
You should specifically try to understand the concepts: Mass, Inertia, Force, Acceleration, Momentum, Velocity, Kinetic energy. They're all related.
I am not familiar with bezier curves, but I need to compare two bezier curves for my project. A quick idea come up in my mind is to sample the two curves and then compare the sampled polylines using something like laplacian coordinates. This way I am comparing the points on the curve, which makes sense. But then I need to worry about the sampling rate. Another idea is to compare the control points of the bezier curves, however I am not sure if it makes sense to do so. Does anyone have experience on doing comparison between bezier curves?
Thanks in advance!
I have an array of sample points with their (X, Y, Z) coordinates. I use Delaunay Triangulation to generate an irregular network from them and then I use linear interpolation to plot contour lines at fixed values (e.g. 90, 95, 100, 105). The problem is that I need smooth contour lines to be generated with another algorithm. I've searched for some time now and found out that I need to use something like Kriging but I'm not that good at math to implement the algorithm from pure mathematical relations. Also I can't seem to find an implementation or explanation of the algorithm anywhere. Can anyone help me find one? Also, am I right with the chosen algorithm? Is there another one that can be easier to implement? Note that I don't care about precision.
https://dl.dropbox.com/u/15926260/ex.png
P.S. I've done a plot in Surfer showing the results that I'm looking for. On the right side is what I have done using triangulation and linear interpolation and on the left side is what I need to plot using a different algorithm (Kriging was used in Surfer).
Sorry for the spelling mistakes but I'm not a native language speaker.
Thank you!
You can try a regular (weighted) delaunay triangulation. In weighted delaunay triangulation triangle areas are more equal. IMO the kriging algorithm seems also to produce more equally contours. Weighted delaunay triangulation is also used to make smoother meshes.