Arc length parametrization using R - r

I am dealing with 2-dimensional parametric curve f.
Is there there is any function in R (in any package) which gives the arc-length parametrization for any such given parametric f?
I know how to derive the arc-length parametrized function from a given function. It involves derivative and integration as here. But looking for whether there is any R function for computation of arc-length parametrization.

The pracma package seems to have the functions you are looking for. See arclength() in particular on page 23 of the pracma documentation.

Related

Is there an R function for deriving digits

Is there there is any function in R (in any package) which gives the arc-length parametrization for any such given parametric f?
I know how to derive the arc-length parametrized function from a given function. It involves derivative and integration as here. But looking for whether there is any R function for computation of arc-length parametrization.

Optimization in R with arbitrary constraints

I have done it in Excel but need to run a proper simulation in R.
I need to minimize function F(x) (x is a vector) while having constraints that sum(x)=1, all values in x are [0,1] and another function G(x) > G_0.
I have tried it with optim and constrOptim. None of them give you this option.
The problem you are referring to is (presumably) a non-linear optimization with non-linear constraints. This is one of the most general optimization problems.
The package I have used for these purposes is called nloptr: see here. From my experience, it is both versatile and fast. You can specify both equality and inequality constaints by setting eval_g_eq and eval_g_ineq, correspondingly. If the jacobians are known explicitly (can be derived analytically), specify them for faster convergence; otherwise, a numerical approximation is used.
Use this list as a general reference to optimization problems.
Write the set of equations using the Lagrange multiplier, then solve using the R command nlm.
You can do this in the OpenMx Package (currently host at the site listed below. Aiming for 2.0 relase on cran this year)
It is a general purpose package mostly used for Structural Equation Modelling, but handling nonlinear constraints.
FOr your case, make an mxModel() with your algebras expressed in mxAlgebras() and the constraints in mxConstraints()
When you mxRun() the model, the algebras will be solved within the constraints, if possible.
http://openmx.psyc.virginia.edu/

Find a primitive function for the antiderivative?

I've been searching on R help for a primitive function, because in my case I can't do it with integrate function, is there any way to find a primitive function (antiderivative)?
If it is a one-off, you can use a computer-algebra system (Maxima, Maple, Wolfram Alpha, etc.).
If you want to do it from R, you can use the Ryacas package.
For instance, yacas(expression(integrate(sin))) returns -Cos(x).
There is no analytical method to generate F where F'=f and f is known but you can always approximate a value for a specific bounds when the bounds is known using the trapezoid approximation for instance.

Generalized Inverse Gamma Distribution in R

Mathematica has a four-parameter generalized inverse gamma distribution:
http://reference.wolfram.com/mathematica/ref/InverseGammaDistribution.html
and gives its PDF on that page too. Has anyone implemented the density, distribution, quantile, and sampling-from functions for that in R?
I did make a quick start (the PDF is just the equations on that page translated into R) but if its done already I'll not bother with implementing the CDF and the quantile function.
Does a general function for computing the CDF (by integration of PDF) and the Quantile (by inversion of the CDF) of any distribution given the PDF exist?
[Note this is not the generalized inverse Gaussian]
Note also the 'Properties and Relations' dropdown on the Mathematica page, which seems to imply its not a special case or generalisation of anything (apart from the inverse gamma).
I started a package to implement this:
https://github.com/barryrowlingson/geninvgamma
Its only using simple inversion and integration of the density, so nothing clever. Currently random samples from the distribution are done by generating a U(0,1) and getting the quantile, which isn't very efficient or very accurate it seems..
Anyway, its a start.
According to this vignette (Appendix C2), the inverse gamma distribution is a special case of the generalized hyperbolic distribution which is implemented by the ghyp package.

MATLAB's quadprog equivalent in R?

What is the equivalent of MATLAB's quadprog function in R in terms of function specification?
Note that it is not the R package quadprog (although the optimization procedure is the identical).
The R library quadprog uses the 'meq' argument to distinguish between equality and inequality constraints whereas MATLAB has separate arguments for these two. The MATLAB approach is far more convenient for my purposes.
It's not a big deal to transform my arguments to fit but it would be a nice convenience if there is an implementation in R that matches the specification in MATLAB.
Note:
MATLAB quadprog documentation
R quadprog documentation
If you can make the translation and you just want a more convenient function you'll have to make your own wrapper. There is no more similar solution in a package. Someone on here might do it for you but it sounds like you can do it yourself.

Resources