[Rcpp-devel] uniroot problem
Dirk Eddelbuettel
edd at debian.org
Tue Dec 24 01:59:30 CET 2019
On 24 December 2019 at 13:45, Shaami wrote:
| Could you please help with the following example? I do not get function
| value at zero using uniroot() in R. Could you suggest something? I want
| function value zero at any point like 2.4, 2.5, 2.6, 4.5, 5.9 etc.
|
| Thank You
|
| x = c(-100, -20, 100, 230, 500, 920, 1000)
| a = c(1000, 12, 300, 0, 100, 300, 750)
| Fn = function(t, x, a){
| sum = 0
| for(i in 1:length(x)){
| sum = sum + punif(t, min=x[i]-a[i], max=x[i]+a[i])
| }
| return(sum)
| }uniroot(function(t){Fn(t, x, a) - 2.4}, interval=c(min(x-a), max(x+a)))
| uniroot(function(t){Fn(t, x, a) - 2.5}, interval=c(min(x-a), max(x+a)))
| uniroot(function(t){Fn(t, x, a) - 2.8}, interval=c(min(x-a), max(x+a)))
What have you tried so far?
Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
More information about the Rcpp-devel
mailing list