Message Boards Message Boards

0
|
2183 Views
|
4 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Smooth an arbitrary curve

Posted 1 year ago

I have a curve that looks nice from a distance but has tiny bobbles. I want to replace it with a smoother curve.

In detail: the curve is a spline through one or two hundred points. end-to-end dimension about 100 units. The points have bobbles on the order of a couple of tenths of a unit, so the curve has corresponding bobbles. I'd like to replace the curve with another curve with less bobbles ... maybe measured by something like the integral of the 3rd derivative, but that differs from the starting curve by less than a couple of tenths (obviously this is a parameter to the process.) Maybe with a requirement that the ends don't move.

Formally speaking: given a parametrized curve c[t], 0 <= t <= 1, find a new curve d[t], so that d[t] is within diff of c[t] for every t, and d is smoother than c by some measure ...

I figure that with all the tools in Mathematica, there's got to be some nice way to do this ...

Thanks ...

POSTED BY: David Golber
4 Replies

Hi David!

You could also try Loess : `https://resources.wolframcloud.com/FunctionRepository/resources/Loess/ , read that post about SMOOTHING splines https://mathematica.stackexchange.com/questions/33206/implementation-of-smoothing-splines-function

Bernstein approximation is another possibility. It depends on your goal and hypotheses...

Regards,

Claude

POSTED BY: Claude Mante
Posted 1 year ago

Hi David,

GaussianFilter is a standard smoothing method for data lists. Its the discrete version of smoothing a function with a moving average produced by the convolution of a piecewise continuous function with a Gaussian kernel ~ Exp[-x^2/sigma] of the normal distributiion.

Smoothing an Interpolation With a Gaussian Filter

This is a noisy data set from x|->(x/3)^2 Sin[2[Pi] x/22].

noisyf =  
  Array[({#, (#/3.0)^2 Sin[2 \[Pi] #/22] + 3.5 #  RandomReal[] } &), {56}, 0];

ListPlot[noisyf  ]

The data set is smoothed

 smoothf[s_]:= 
  smoothf[s] = 
(Transpose[  {#[[1]],  GaussianFilter[#[[2]], s] }] &)[Transpose[noisyf]];

Manipulate[
 Show[{ ListPlot[noisyf  , PlotStyle -> {Red, Opacity[0.5]},  Joined -> True], 
   ListPlot[smoothf[n], PlotStyle -> {Blue}, Joined -> True]}],
 {n,   Range[0, 7, 0.5]}]

Regards Roland

POSTED BY: Updating Name
Posted 1 year ago

Thanks ... I figured there was something like this. I'll see how it works with my stuff.

POSTED BY: David Golber

Please provide your efforts in the form of the Wolfram Language code. This will make it easier for other members to help you. Check several methods available to include your code in the rules http://wolfr.am/READ-1ST

POSTED BY: Moderation Team
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract