Calculate differential in Fortran [closed] - math

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I want to calculate w for j=0 to n in the below function. Is there any already written library for this in FORTRAN?
Actually I want to write a program that get n from the user, and print w in output. What shall I do for differential and for creating the equation Ln(x)?

That recurrence relation will generate the n-th order Legendre polynomial, and from the xj and wj, I assume you are writing a program to perform Gauss-Legendre integration (no idea why the q(x) is there).
This Florida State page provides an LGPL Fortran90 program that calculates the nodes and weights using a tridiagonal-eigenvalue method and writing them to an external file. You could try and collect all of the contained functions and place them into a module for run-time calculation of the nodes and weights.

Related

Global Optimization with bounds in R [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I am looking for an optimzier that minimizes a least square problem (non-linear) for a global minimum with constraints.
I was trying to use SANN optimization in R but realised that it doesnt allow constaints. I actually just want to bind my constraint to >0 and <1.
Is there a package available for that?
Thank you very much in advance.
You could apply optim with "L-BFGS-B", which directly allows constraints. If the results are very sensitive to initial parameters, then you could minimise over a grid of initial values supplied to par and then choose the parameters that give the best result.
You could also use "SANN" with optim (or any other unconstrained optimiser), but change your initial objective function such that it's automatically constrained. For example, if you really want to minimise wrt \beta but \beta must lie between 0 and 1, then you could instead instead minimise wrt \tau and replace \beta by exp(\tau)/(1+exp(\tau)) (the logit function) in your objective function. It'll always be between 0 and 1 then.

R language how to do optimization with either/or constraints? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I am trying to do constrained optimization using R. My constraint is not continuous. Here is an example:
minimize: f(x,y)=(x-2)^2+y^2
st. x=0 or x>=3
y=0 or y>=2
What type of optimization problem is this?
These are called semi-continuous variables. Some solvers support these directly, but they can also be formulated with additional binary variables:
3*d <= x <= 1000*d
d binary
Anyway, you end up with a MIQP model (Mixed Integer Quadratic Programming). Solvers like Gurobi and Cplex support this and have R interfaces.

Is there a way to inform classifiers in R of the relative costs of misclassification? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
This is a general question. Are there classifiers in R -- functions that perform classification implementing classification algorithms-- that accept as input argument the relative cost of misclassification. E.g. if a misclassification of a positive to negative has cost 1 the opposite has cost 3.
If yes which are these functions?
Yes. If you are using the caret package (you should; it provides 'standardization' for 200+ classification and regression methods by wrapping almost all relevant R's packages), you can set the weights argument of the train function (see p.152; see also here) for models that support class weights. This answer lists some of the models that support class weights.

R generate random vectors from multivariate distributions [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I want to generate random points of uniform density over the unit ball [-1,1]^d in R.
Are there any R packages which offer this functionality?
I am sure i can do this myself by extending this answer: https://math.stackexchange.com/a/87238/250498 to d dimensions.
But i want to know if there is any function or package in R that already does this.
It would be useful if there is a package which can generate standard multivariate distributions instead of me having to sample them myself using rejection sampling or other techniques.

spline approximation with specified number of intervals [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
So - edited because some of us thought that this question is off-topic.
I need to build spline (approximation) on 100 points in one of environments listed in tags. But I need it with exact number of intervals (maximum of 6 intervals - separate equations - in whole domain). Packages / libraries in R and Maxima which I know let me for building spline on this points but with 25-30 intervals (separate equations). Does anyone know how to build spline with set number of intervals without coding whole algorithm all over again?
What you're looking for might be described as "local regression" or "localized regression"; searching for those terms might turn up some hits.
I don't know if you can find exactly what you've described. But implementing it doesn't seem too complicated: (1) Split the domain into N intervals (say N=10). For each interval, (2) make a list of the data in the interval, (3) fit a low-order polynomial (e.g. cubic) to the data in the interval using least squares.
If that sounds interesting to you, I can go into details, or maybe you can work it out yourself.

Resources