From: Roger Stafford on
"Luca Turchet" <tur(a)imi.aau.dk> wrote in message <hs3g9h$7u4$1(a)fred.mathworks.com>...
> Dear Bruno,
> thanks a lot.
>
> The problem is that I need to calculate the x,y coordinates of the point which is at a given distance from another point along the curve.
>
> Let´s say A = (x1, f(x1)) where f = normal distribution
> I need to find B = (x2, f(x2)) such that the distance between A and B is equal to a specified value, for example 2.
>
> Do you have any idea how to do this?
- - - - - - - - -
As a suggestion, use the function 'cumtrapz' with the integrals suggested by Bruno and Torsten with sufficiently close spacing of points starting at point A to give the accuracy you need with trapezoidal integration. Then your task is to locate within the 'cumtrapz' vector result, that value that first exceeds the desired distance. The 'find' function with an inequality can help you do this. Then in the last interval you can make an appropriate linear adjustment to locate the point B within it accurately.

This might be less time consuming than using 'fzero' which would require numerous repeated integrations all starting back at point A.

Roger Stafford
From: Bruno Luong on
Sorry for the typo:

> Yes once you are able to compute the length, use FZERO to find where is the second point. Torsten has answered this in other thread.
>
> Bruno
From: Luca Turchet on
Dear all,
thanks for all the suggestions. I have understood the procedure.
Unfortunately I have bad memories about my previous math studies ;-( so maybe this question can make you laugh:

Which is the derivative of the normal function?
I have not been able to find it. If you can give me the function I would really appreciate this.
Is there any MATLAB function allowing me to calculate it?

Moreover, in matlab is there a function to calculate y = normal(x, mu, sigma)
for a given x?


Best





"Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hs3ikh$7g9$1(a)fred.mathworks.com>...
> Sorry for the typo:
>
> > Yes once you are able to compute the length, use FZERO to find where is the second point. Torsten has answered this in other thread.
> >
> > Bruno
From: Bruno Luong on
Here is the function that computes 1D gaussian pdf and its derivative

function [f dfdx] = gaussian(x, m, s)

a = 1/sqrt(2*pi*s);
y = (x - m)/s;
f = a*exp(-y.^2/2);
dfdx = -y.*f/s;

end
From: John D'Errico on
"Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hs3iir$49g$1(a)fred.mathworks.com>...
> "Luca Turchet" <tur(a)imi.aau.dk> wrote in message <hs3g9h$7u4$1(a)fred.mathworks.com>...
> > Dear Bruno,
> > thanks a lot.
> >
> > The problem is that I need to calculate the x,y coordinates of the point which is at a given distance from another point along the curve.
> >
> > Let´s say A = (x1, f(x1)) where f = normal distribution
> > I need to find B = (x2, f(x2)) such that the distance between A and B is equal to a specified value, for example 2.
> >
> > Do you have any idea how to do this?
> - - - - - - - - -
> As a suggestion, use the function 'cumtrapz' with the integrals suggested by Bruno and Torsten with sufficiently close spacing of points starting at point A to give the accuracy you need with trapezoidal integration. Then your task is to locate within the 'cumtrapz' vector result, that value that first exceeds the desired distance. The 'find' function with an inequality can help you do this. Then in the last interval you can make an appropriate linear adjustment to locate the point B within it accurately.
>
> This might be less time consuming than using 'fzero' which would require numerous repeated integrations all starting back at point A.
>
> Roger Stafford

Another option is to use ode45. It can integrate
the arclength term. Then set it so that it finds the
specific arclength that you need. This is actually
the best way to solve the problem. For more details,
look at my arclength and interparc codes on the
file exchange. interparc does a spline arclength
integral.

Alternatively, you could just sample the Gaussian
curve and then call one of these codes.

Of course, since this is surely for homework, neither
alternative is probably an option.

John