Remove the for loop and all the [i]'s in your code and it will probably go
faster. I.e., change
f0 <- function (lines)
{
numbers <- vector("numeric")
for (i in 1:length(lines)) {
lines[i] <- sub("[^ ]+ +", "", lines[i])
lines[i] <- gsub(" ", "", lines[i])
numbers <
> peter dalgaard
> on Fri, 8 Sep 2017 16:12:21 +0200 writes:
>> On 8 Sep 2017, at 15:51 , Martin Møller Skarbiniks
>> Pedersen wrote:
>>
>> On 8 September 2017 at 14:37, peter dalgaard
>> wrote:
>>>
>>>
On 8 Sep 2017, at 14:03 , peter dalgaard
> On 8 Sep 2017, at 15:51 , Martin Møller Skarbiniks Pedersen
> wrote:
>
> On 8 September 2017 at 14:37, peter dalgaard wrote:
>>
>>
>>> On 8 Sep 2017, at 14:03 , peter dalgaard wrote:
>>>
>>> x <- scan("~/Downloads/digits.txt")
>>> x <- x[-seq(1,22,11)]
>>
>> ...and, come to think of
On 8 September 2017 at 14:37, peter dalgaard wrote:
>
>
> > On 8 Sep 2017, at 14:03 , peter dalgaard wrote:
> >
> > x <- scan("~/Downloads/digits.txt")
> > x <- x[-seq(1,22,11)]
>
> ...and, come to think of it, if you really want the 100 random digits:
>
> xx <- c(outer(x,10^(0:4), "%/%")
> On 8 Sep 2017, at 14:03 , peter dalgaard wrote:
>
> x <- scan("~/Downloads/digits.txt")
> x <- x[-seq(1,22,11)]
...and, come to think of it, if you really want the 100 random digits:
xx <- c(outer(x,10^(0:4), "%/%")) %% 10
--
Peter Dalgaard, Professor,
Center for Statistics, Copen
Hi
see in line
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Martin
> Moller Skarbiniks Pedersen
> Sent: Friday, September 8, 2017 11:58 AM
> To: r-help@r-project.org
> Subject: Re: [R] Optimize code to read text-file wi
Simplest version that I can think of:
x <- scan("~/Downloads/digits.txt")
x <- x[-seq(1,22,11)]
length(x) # 20
hist(x)
Now, because it's Friday:
How does one work out the theoretical distribution of the following table?
> table(table(factor(x,levels=0:9)))
0 1 2 3
On 8 September 2017 at 11:25, PIKAL Petr wrote:
> > Moller Skarbiniks Pedersen
> My program which is slow looks like this:
> >
> > filename <- "digits.txt"
> > lines <- readLines(filename)
>
> why you do not read a file as a whole e.g. by
>
> lines<-read.table("digits.txt")
>
Good idea.
>
> An
Hi
see in line
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Martin
> Moller Skarbiniks Pedersen
> Sent: Friday, September 8, 2017 10:49 AM
> To: r-help@r-project.org
> Subject: [R] Optimize code to read text-file with digits
&
Hi,
Every day I try to write some small R programs to improve my R-skills.
Yesterday I wrote a small program to read the digits from "A Million
Random Digits" from RAND.
My code works but it is very slow and I guess the code is not optimal.
The digits.txt file downloaded from
https://www.ra
optimr/optimrx are for unconstrained and bounds constrained problems.
I think you are going to have to do the masking yourself. It's more messy and
tedious than
difficult. The optimization is on a new set of parameters newpar that has
fewer components, so in your objective function and constraint
Thanks Prof Nash.
The reason I used nlopr() in my problem is due to non linear
constraints. I wonder if optimrx/optim can model the below scenario. I
will be elated if it can.
The problem in hand goes like this:
There are 2 injectors and 2 producers. Consider these as some entity.
I have an actua
I refer to such parameters as "masked" in my 2014 book Nonlinear parameter
optimization with R tools.
Recently I put package optimrx on R-forge (and optimr with fewer solvers on
CRAN) that allows for masks with
all the parameters. The masks can be specified as you suggest with
start=lower=upper.
You provided the data but not the broken code.
--
Sent from my phone. Please excuse my brevity.
On October 19, 2016 2:59:08 PM PDT, Narendra Modi wrote:
>Hello All,
>I have a matrix with initial values as below and I need to optimize
>the variables that are greater than 0.
>
> TAU
Hello All,
I have a matrix with initial values as below and I need to optimize
the variables that are greater than 0.
TAU fij fij2
[1,] 14.33375 0.000 0.01449572
[2,] 14.33375 0.000 0.
[3,] 14.33375 0.000 0.
[4,] 14.33375 0.000 0.02206446
[
The nested for-loops could very easily be moved to Rcpp which should speed them
up. Using apply functions instead of for-loops will not make it faster; they
still have to do the same looping.
At least, when I use `outer` to replace the loop I get roughly the same speed
for the two versions —
Hello
I have two for loops that I am trying to optimize... I looked for
vectorization or for using some funcions of the apply family but really
cannot do it. I am writting my code with some small data set. With this
size there is no problem but sometimes I will have hundreds of rows so it
is real
1.12329 0.68861 1.23011 1.49413 0.01698659
...
11 ...
...
2150...
...
55999 1.19111 1.48329 0.8806591.82682 0.037803564
56000 1.11901 1.12973 0.5230261.92828 0.038733914
--
View this message in context:
http://r.789695.n4.nabble.com/RSM-in-R-optimize-minimize-a-response-tp47
Yup. And books don't rewrite themselves when the software changes, so if things
don't seem to work, check the _current_ documentation.
-pd
On 01 Oct 2014, at 21:53 , William Dunlap wrote:
> Change your 'max=T' to 'maximum=TRUE'. A long time ago the '...' in
> optimize's argument
> list was a
Change your 'max=T' to 'maximum=TRUE'. A long time ago the '...' in
optimize's argument
list was at the end, so you could abbreviate any of its argument
names. Now the '...' is the
third formal argument, so all the trailing arguments meant for
optimize itself must be fully
spelled out. Otherwise
Page 53 of Robert and Casella's "Use R" book, Introduction to Monte Carlo
Methods with R, has the following code:
optimize(f=function(x){dbeta(x,2.7,6.3)},
+ interval=c(0,1) ,max=T)$objective
This should return
[1] 2.669744
I run R from R Studio. When I enter this code I receive the
Hello,
Thanks a lot for the replies.
I tried to use the "optim" function in R, and chose the "L-BFGS-B" method
of optimization. Now the result is very sensitive to the starting values. I
use the same function, but I give the line of code I use for "optim".
optim(0.25, f, method= "L-BFGS-B", low
lap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of William Dunlap
> Sent: Monday, October 28, 2013 3:03 PM
> To: Rolf Turner; Shantanu MULLICK
> Cc: r-help@r-project.org
> Subject: Re: [R] O
n, with its log=TRUE
and
perhaps lower.tail=FALSE arguments.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Rolf Turner
> Sent: Monday, October 28
This could be described as a bug, perhaps. Or it could be described as
an indication that numerical optimization is inevitably tricky. Notice that
if you narrow down your search interval from [0,5] to [0,0.5] you get the
right answer:
> optimize(f, c(0, 0.5), maximum= TRUE,tol=1e-10)
$maximum
[
Hello,
This seems like a bug, removing 'maximum = TRUE' has no effect except
that the returned value says it's a minimum, not a maximum.
Rui Barradas
Em 28-10-2013 17:00, Shantanu MULLICK escreveu:
Hello Everyone,
I want to perform a 1-D optimization by using the optimize() function. I
want
Hello Everyone,
I want to perform a 1-D optimization by using the optimize() function. I
want to find the maximum value of a "logistic" function. The optimize()
function gives the wrong result.
My code:
f= function (k) {
T_s = 20
result = (2- 2/(1+ exp(-2*T_s*k)))
return(result)
}
optimize(f, c(0
On Tue, 23 Jul 2013, Christof Kluß writes:
> Am 23-07-2013 13:20, schrieb Enrico Schumann:
>
>> On Tue, 23 Jul 2013, Christof Kluß writes:
>>
>>>
>>> I have "observations" obs <- (11455, 11536, 11582, 11825, 11900, ...)
>>>
>>> and a simulation function f(A,B,C,D,E,F), so sim <- f(A,B,C,D,E,F)
Hi
the integer values in the vectors sim and obs are dates
when I set sim <- f(TS0,TS1,TS2,TB0,TB1,TB2) my A,..,F below
then TS0 and TB0 are depend (and so on)
the main thing in f(...) is something like
for (i in c(1:length(temperature))) {
Temp <- temperature[i]
if (DS < 0) {
On Tue, 23 Jul 2013, Christof Kluß writes:
>
> I have "observations" obs <- (11455, 11536, 11582, 11825, 11900, ...)
>
> and a simulation function f(A,B,C,D,E,F), so sim <- f(A,B,C,D,E,F)
>
> e.g. sim = c(11464, 11554, 11603, 11831, 11907, ...)
>
> now I would like to fit A,B,C,D,E,F such that "
Hi
I have "observations" obs <- (11455, 11536, 11582, 11825, 11900, ...)
and a simulation function f(A,B,C,D,E,F), so sim <- f(A,B,C,D,E,F)
e.g. sim = c(11464, 11554, 11603, 11831, 11907, ...)
now I would like to fit A,B,C,D,E,F such that "obs" and f(A,B,C,D,E,F)
match as well as possible. A
Dear list,
I am running into 2 problems when using the optimize function from the
stats package (note: I've also tried unsuccessfully to use optim,
nlm, & nlminb). The second problem is caused by my solution to the
first, so I am asking if anyone has a better solution to the first
question, or i
On Thu, Aug 2, 2012 at 5:58 AM, loyolite270 wrote:
> oh sorry ..
>
> The detailed description of the problem is given below
>
> dataFrame is matrix of dim 100X100 with some values
Odd name for something that's not a dataFrame (i.e., data.frame != matrix)
> a is a vector of length 1
> x is a
oh sorry ..
The detailed description of the problem is given below
dataFrame is matrix of dim 100X100 with some values
a is a vector of length 1
x is a vector of any length between 1 to 99
funcScore<-function(a,x){
sc<-0
sc1<-0
for(j in 1:(length(x))){
sc<-sc+abs(d
You'll have to give a more realistic description to get detailed help:
otherwise, look up "combinatorial optimization" and "parallelization"
for some generic pointers.
Best,
Michael
On Wed, Aug 1, 2012 at 11:34 AM, loyolite270 wrote:
> Thanks for the reply, but the example i have given above is
Thanks for the reply, but the example i have given above is a sample
function. I would be using a function with input vector of size more than
100 and the function will compute some score based on the 100 vector
combinations.
Since i don't want to do this computation sequentially for all these
com
On Aug 1, 2012, at 16:34 , Sarah Goslee wrote:
> combn() gives ordered combinations, while expand.grid() gives all
> combinations.
...and there's one more function that is designed to tabulate a function of two
variables over a grid. And yet another one to find which value is max in an
array
combn() gives ordered combinations, while expand.grid() gives all combinations.
I'd give worked code but this hints at homework to me.
Sarah
On Wed, Aug 1, 2012 at 10:23 AM, Eik Vettorazzi wrote:
> Hi,
> not sure if that is what you are looking for, but have a look at
>
> cmb<-t(combn(c(0,3,5,8
Hi,
not sure if that is what you are looking for, but have a look at
cmb<-t(combn(c(0,3,5,8),2)) #get all pairs of combinations
cbind(cmb,apply(cmb,1,diff)) #for each pair, get the difference
cheers
Am 01.08.2012 12:29, schrieb loyolite270:
> Hi
>
> I need to optimize the below function:
>
Hi
I need to optimize the below function:
a=function(x){
A=x[1]
B=x[2]
C=B-A
return(C)
}
I need to optimize the above function such that x can be any combination of
these number (0,3,5,8) of vector length 2
(i.e) x can be (3,0), (5,0), (8,0), (3,5), (3,8), (5,8), .. etc
can s
Wow...it's so simple! I have specified the variable times.
Thank you so much, Ben!
--
View this message in context:
http://r.789695.n4.nabble.com/optimize-tp4173920p4192278.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-pro
dnz.marcio gmail.com> writes:
>
[snip]
> # Logaritmo da distribuição condicional de alpha[i]
>
> lp_alphai <- function(alphai, i, beta, tau, N){
>
> t1 <- (N[i+1] - N[i])*log(alphai)
> t2 <- - (N[i+1] - N[i])*alphai*log(beta[i])
> t3 <- (alphai - 1)*sum(log(times[(N[i] + 1):N[i+1]]))
>
Hi!
I have a difficulty in the use of function optimize(). Could you help me?
I want to maximize this function:
# Logaritmo da distribuição condicional de alpha[i]
lp_alphai <- function(alphai, i, beta, tau, N){
t1 <- (N[i+1] - N[i])*log(alphai)
t2 <- - (N[i+1] - N[i])*alphai*log(beta[i])
quot;
>Sent: Wednesday, October 5, 2011 11:54 AM
>Subject: Re: [R] optimize R code: replace for loop
>
>You can vectorize it using cumsum.
>
>cumsum(c(1, testvec))
>
>all.equal(final.sum, cumsum(c(1, testvec)))
>
>> -Oorspronkelijk bericht-
>> Van: r-h
; Aan: r-help@r-project.org
> Onderwerp: [R] optimize R code: replace for loop
>
> Dear R Users,
>
> at the moment I am trying to optimize an R script.
>
> testvec <- c(0,1,0,1,1,1,1,0,0,1,0,1,0)
>
>
> sum.testvec <- vector()
> tempsum <- 1
> for (e
Dear R Users,
at the moment I am trying to optimize an R script.
testvec <- c(0,1,0,1,1,1,1,0,0,1,0,1,0)
sum.testvec <- vector()
tempsum <- 1
for (e in 1:length(testvec)){
sum.testvec[e] <- tempsum+testvec[e]
tempsum <- sum.testvec[e]
}
final.sum <- c(1,sum.testvec)
Is there an option to do
Hi,
I have a simple problem where I have two or more predictor variables that
range from 0 to 1 and binary response variable (0 or 1). In the two
variable case, the model to fit with maximum likelihood would simply be:
P(Y=1) = (B1*X1 + B2*X2)/(B1+B2)
or if least squares is to be minimized
On Jan 3, 2011, at 11:09 AM, Muhammad Rahiz wrote:
Josh's recommendation to use predict works. At the same time, I'll
work on your suggestions, David.
Thanks.
Muhammad Rahiz
Researcher & DPhil Candidate (Climate Systems & Policy)
School of Geography & the Environment
University of Oxford
O
Josh's recommendation to use predict works. At the same time, I'll work on
your suggestions, David.
Thanks.
Muhammad Rahiz
Researcher & DPhil Candidate (Climate Systems & Policy)
School of Geography & the Environment
University of Oxford
On Mon, 3 Jan 2011, David Winsemius wrote:
On Jan 3,
On Jan 3, 2011, at 9:52 AM, Muhammad Rahiz wrote:
Hi all,
I'm trying to get the value of y when x=203 by using the intersect
of three curves. The horizontal curve does not meet with the other
two. How can I rectify the code below?
Thanks
Muhammad
ts <- 1:10
dd <- 10:1
ts <- seq(200,20
On Jan 3, 2011, at 9:52 AM, Muhammad Rahiz wrote:
Hi all,
I'm trying to get the value of y when x=203 by using the intersect
of three curves. The horizontal curve does not meet with the other
two. How can I rectify the code below?
Extend the appropriate axes. xlim and ylim are the argume
Hi Muhammad,
On Mon, Jan 3, 2011 at 6:52 AM, Muhammad Rahiz
wrote:
> Hi all,
>
> I'm trying to get the value of y when x=203 by using the intersect of three
> curves. The horizontal curve does not meet with the other two. How can I
> rectify the code below?
What is your code supposed to do? Thi
Hi all,
I'm trying to get the value of y when x=203 by using the intersect of
three curves. The horizontal curve does not meet with the
other two. How can I rectify the code below?
Thanks
Muhammad
ts <- 1:10
dd <- 10:1
ts <- seq(200,209,1)
dd <- c(NA,NA,NA,NA,1.87,1.83,1.86,NA,1.95,1.9
peter dalgaard gmail.com> writes:
>
> On Dec 6, 2010, at 15:15 , Jonathan P Daily wrote:
>
> > Correct me if I'm wrong, but isn't the minimal x value in your example
> > the same regardless of what positive coefficient you apply to x? If that
> > is the case, you would expect the same min(x) for
org; sandra lag
Subject: Re: [R] Optimize multiple variable sets
I suppose I should have been more clear. I saw that her interval did not
include the actual minimum, but I was asking if (and if, why) she was
expecting the minimum x value to be different for each run. If the y value
were returned t
uot;Is the room still a room when its empty? Does the room,
the thing itself have purpose? Or do we, what's the word... imbue it."
- Jubal Early, Firefly
peter dalgaard wrote on 12/06/2010 09:39:43 AM:
> [image removed]
>
> Re: [R] Optimize multiple variable
On Dec 6, 2010, at 15:15 , Jonathan P Daily wrote:
> Correct me if I'm wrong, but isn't the minimal x value in your example the
> same regardless of what positive coefficient you apply to x? If that is
> the case, you would expect the same min(x) for each iteration.
>
> i.e. in the interval [0
the word... imbue it."
- Jubal Early, Firefly
r-help-boun...@r-project.org wrote on 12/06/2010 07:00:57 AM:
> [image removed]
>
> [R] Optimize multiple variable sets
>
> sandra lag
>
> to:
>
> r-help
>
> 12/06/2010 08:54 AM
>
> Sent by:
Hi,
I usually use optimize function for ML Estimation. Now I´ve got a data frame
with many sets, but I can´t save estimates each time I run the code for each
data set (I´m using a for loop with my loglikelihood function and works ok but
when I apply another for loop to:
optimize(my.loglikeliho
equations.
Ravi.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Michael S.
Sent: Saturday, October 23, 2010 8:06 PM
To: r-help@r-project.org
Subject: [R] Optimize parameters of ODE Problem which is solved numeric
Hi,
I have a data
Hi,
I have a data-matrix:
> PID
sato hrs fim health
214 3 4.376430 6.582958 5
193 6 4.361825 3.138525 6
8441 6 4.205771 3.835886 7
7525 6 4.284489 3.245139 6
6806 7 4.168926 2.821833 7
5682 7 1.788707 1.212653 7
5225 6 1.
I would run 200 iterations of nnet() such that optimization is done for 'f',
where f = error_cross_validation * (error_cross_validation /
error_training_set). Any guidance on how to optimize for this per-cycle
dependent variable (f) is appreciated.
Thank you,
supra
[[alternative HTML vers
Hi
I'm trying to maximize a joint likelihood of 2 likelihoods (Likelihood 1 and
Likelihood 2) in mle2, where the parameters I estimate in Likelihood 2 go
into the likelihood 1. In Likelihood 1 I estimate the vector logN with
length 37, and for the Likelihood 2 I measure a vector s of length 8.
Hi Andrew,
Just remember that something was bad with the code I sent you (the same you
referred to in [1]).
This version runs with no problems:
# Some data
history_ <-
data.frame(person_id=c(1,2,2),date_=c("2009-01-01","2009-02-03","2009-02-02"),x=c(0.01,0.05,0.06))
colnames(history_) <- c("perso
On Fri, Feb 27, 2009 at 2:10 PM, William Dunlap wrote:
> Andrew, it makes it easier to help if you supply a typical
> input and expected output along with your code. I tried
> your code with the following input:
I'll be careful to avoid these mistakes. Also, I should not have used
a reserved wo
[,"person_id"]),,drop=FALSE]
history[order(history$date),,drop=FALSE]
}
> f2(history)
person_id date
2 Mary2
7 Alex7
9Sue9
10 Joe 10
Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com
Dear Andrew:
Here is another way assuming you have an order column in your history data
as well as a person_id. Again, your variable
of interest is x:
# Some data
set.seed(1)
history<-data.frame(
person_id=rep(1:10,each=10),
record=rep(sample(10),10),
x=rnorm(100)
"...from an SQL database."How? Structure of the result?
You say "ordered by date" but then you don't reference any date
variable? And your code creates an "order" column, but that would not
appear necessary for the stated purpose and you don't output the last
"order" within a "person_i
Dear Andrew,
Here is one way:
# Some data
set.seed(1)
mydata<-data.frame(person_id=rep(1:10,10),x=rnorm(100))
mydata
# last register for person_id
with(mydata,tapply(x,person_id,function(x) tail(x,1)))
# test for person_id=1
mydata[mydata$person_id==1,] # see the last number in column 2
HTH,
I want to find the last record for each person_id in a data frame
(from a SQL database) ordered by date. Is there a better way than
this for loop?
for (i in 2:length(history[,1])) {
if (history[i, "person_id"] == history[i - 1, "person_id"])
history[i, "order"] = history[i - 1, "order"]
.
EToktar
> -Original Message-
> From: Marc Schwartz [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 05, 2008 1:12 PM
> To: Spencer Graves
> Cc: [EMAIL PROTECTED]; r-help@r-project.org
> Subject: Re: [R] optimize simultaneously two binomials
> inequalities using nlm(
Thanks Mr. Graves for your support.
> I saw your post on 7/29, and I have not seen a reply,
> so I will attempt a response to the question at the start of
> your email:
>
> obtain the smallest value of 'n' (sample size) satisfying
> both inequalities:
>
> (1-alpha)
Just a quick follow up to Spencer's post, you might want to look at the
AcceptanceSampling package on CRAN:
http://cran.r-project.org/web/packages/AcceptanceSampling/index.html
HTH,
Marc Schwartz
on 08/05/2008 09:00 AM Spencer Graves wrote:
I saw your post on 7/29, and I have not seen a
I saw your post on 7/29, and I have not seen a reply, so I will
attempt a response to the question at the start of your email:
obtain the smallest value of 'n' (sample size)
satisfying both inequalities:
(1-alpha) <= pbinom(c, n, p1) && pbinom(c, n, p2) <= beta,
where alpha, p1,
Dear R users,
I´m trying to optimize simultaneously two binomials inequalities (used in
acceptance sampling) which are nonlinear solution, so there is no simple
direct solution. Please, let me explain shortly the the problem and the
question as following.
The objective is to obtain the smallest v
Dear R users,
I´m trying to optimize simultaneously two binomials inequalities used to
acceptance sampling, which are nonlinear solution, so there is no simple
direct solution. Please, let me explain shortly the the problem and the
question as following.
The objective is to obtain the smallest v
Dear R users,
I´m trying to optimize simultaneously two binomials inequalities used to
acceptance sampling, which are nonlinear solution, so there is no simple
direct solution.
The 'n' represents the sample size and the 'c' an acceptance number or
maximum number of defects (nonconforming) in sampl
Hi,
I have the following jackknife code which is much slower than my colleagues C
code. Yet I like R very much and wonder how R experts would optimize this.
I think that the for (i in 1:N_B) part is bad because Rprof() said sum() is
called very often but I have no idea how to optimize it.
#
-Original Message-
From: Mike Lawrence [mailto:[EMAIL PROTECTED]
Sent: Monday, October 01, 2007 10:27 AM
To: Ravi Varadhan
Cc: 'Rhelp'
Subject: Re: [R] optimize() stuck in local plateau ?
I may be misunderstanding, but my example seems to v
p://www.jhsph.edu/agingandhealth/People/Faculty/
> Varadhan.html
>
>
>
> --
> --
>
>
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org]
alth/People/Faculty/Varadhan.html
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Mike Lawrence
Sent: Monday, October 01, 2007 1:29 AM
To: Rhelp
Subject: [R] optimize() stuck in local plateau ?
Hi all,
Consider the
Given a univariate problem where the maximum
must be between -1 and 1, I would test with a grid
of points, then refine that if necessary.
Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")
Mike Lawrence wrote:
>
Hi Mike,
You function is discontinuous at -0.8, so you can
expect everything :-}! But this is not the only
problem. The algorithm for optimize never gets there.
In general there exists no universal method to find
the global maximum of a function (unless it satisfies
certain conditions). You can al
Hi all,
Consider the following function:
my.func = function(x){
y=ifelse(x>-.5,0,ifelse(x< -.8,abs(x)/2,abs(x)))
print(c(x,y)) #print what was tested and what the result is
return(y)
}
curve(my.func,from=-1,1)
When I attempt to find the maximum of this function,
84 matches
Mail list logo