Carl Love

Carl Love

28100 Reputation

25 Badges

13 years, 103 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@Joe Riel There's also ArrayTools:-IsZero.

The index spec in the rtable_scanblock command can be shortened to [i, ..].

@vv I modifed the code for the animation so that the memory usage is only 20M.

@Christopher2222 No, is won't work in this case. AFAIK, there are no cases where the default boolean evaluator returns a truefalse result and is returns a different result. Sometimes is can make finer distinctions in cases where the default evaluator returns an ambiguous result. That's not the case here: The default evaluator returns false because the addresses of the vectors are different; it couldn't care less about the contents of the vectors---it only checks addresses. The situation would be different if one were comparing lists rather than vectors. The evaluator still just checks addresses, but because of the way that Maple stores lists, lists that are equal are necessarily stored at the same address. How's that? When new lists (and many other structures) are created, they are compared against existing lists for matches in a part of Maple called the "simplification table." (See the "Simplification Table" section in Appendix A of the Maple Programming Guide.) That's part of the reason why it's inefficient to iteratively lenghten lists (or sequences, or sets).

@student_md You wrote:

  • limit(sum(diff(Fn,Xn)*Xn,n=1..N),N=infinity)

If this expression makes sense at all, then it's equivalent to

sum(diff(F[n], X[n])*X[n], n= 1..infinity);

But I think that having an infinite number of X's is quite odd.

@umar khan You say that you want to "iterate" P(r) to find the root. That type of low-level operation is usually not necessary in Maple. The main command for finding roots is fsolve. It does the iterating in the background.

@Preben Alsholm I'm using Digits = 15. Is that perhaps the cause of the difference?

@Axel Vogt Symbolic dsolve automatically converts floats to fractions unless you explicitly tell it not to by using option convert_to_exact= false.

There is no attachment to your Question.

@Christian Wolinski In modern Maple, the above procedure can be simplified to

H:= proc() try args[[op](procname)] catch: 'procname'(args) end try end proc:

That's about as close to builtin as you can get. I think that that'll work in any version after and including Maple 6.

@brian bovril It's pretty trivial: Just a one-line for loop is needed. Here's the whole worksheet again, with the additional information at the end.
 

restart:

#Adjustment factors:
AdjFact:= Record(
   ':-Wmu'= 5,    ':-Wsigma'= -7, #winner's factors
   ':-Lmu'= -100, ':-Lsigma'= -60 #loser's factors
):

RC:= proc(W::record(mu,sigma), L::record(mu,sigma))
local
   t,
   dist:= evalf@unapply(Statistics:-CDF(Normal(W:-mu, W:-sigma), t), t),
   postW:= Record(
      ':-mu'= W:-mu + AdjFact:-Wmu*dist(W:-mu),
      ':-sigma'= W:-sigma + AdjFact:-Wsigma*dist(W:-mu)
   ),
   postL:= Record(
      ':-mu'= L:-mu + AdjFact:-Lmu*dist(L:-mu),
      ':-sigma'= L:-sigma + AdjFact:-Lsigma*dist(L:-mu)
   )
;
   userinfo(
      1, RC,
      sprintf(
         "Winner = %d +- %d; Loser = %d +- %d.",
         round~([postW:-mu, postW:-sigma, postL:-mu, postL:-sigma])[]
      )
   );
   postW, postL
end proc:

Update:= proc(
   Standings::table,
   Games::list([{name,string}, {name,string}]),
   {inplace::truefalse:= true}
)
local
   R:= `if`(inplace, Standings, copy(Standings)),
   G
;
   for G in Games do
      if assigned(R[G[1]]) and assigned(R[G[2]]) then
         (R[G[1]], R[G[2]]):= RC(R[G[1]], R[G[2]])
      else
         error "Player %1 or %2 not found in Standings", G[]
      end if
   end do;
   `if`(inplace, [][], eval(R))
end proc:
      

#Example usage (using exactly the same scenario as you did):

#Initial standings ("laws"):
Standings:= table([
   A1= Record(mu= 1007, sigma= 47),
   A2= Record(mu= 806,  sigma= 42),
   B1= Record(mu= 1163, sigma= 81),
   B2= Record(mu= 816,  sigma= 44)
]):

#Account of wins\losses (in each pair, the first member defeats the second):
Games:= [[B1,A1], [A1,B2], [B1,A2], [A2,B2]]:

#infolevel[RC]:= 1:

NewStandings:= Update(Standings, Games, inplace= false):

<op(eval(NewStandings))>;

Vector[column]([[A2 = Record(mu = 808.499824704434, sigma = 38.4998948226602)], [A1 = Record(mu = 1006.79431881513, sigma = 41.8765912890772)], [B1 = Record(mu = 1168.00000000000, sigma = 74.0000000000000)], [B2 = Record(mu = 756.590048730233, sigma = 8.3540292381394)]])

#Calculate change in means:
for P in indices(Standings, nolist) do
   printf("%a: %+d\n", P, round(NewStandings[P]:-mu - Standings[P]:-mu))
end do:

A2: +2

A1: +0
B1: +5
B2: -59

NULL


 

Download UpdateStandings.mw

@Christian Wolinski procname always refers to the innermost prodecure in which it occurs. In this case, that's g.

args also applies to the innermost procedure in which it occurs. In this case, that's f. args[1] is a kernel operation; it can't be any simpler that that.

@MrYouMath I have nothing against Tom Leslie's answer; it's totally correct. But I can't see how it's what you're looking for and mine isn't. Didn't you say that you want to use alpha (implicit function) rather than alpha(t) (explicit function)?

@sand15 Statistics:-Sample is a fine way to solve the problem. It's quite efficient for the "known" distributions. It simply hadn't occurred to me to mention it. The job can also be done by LinearAlgebra:-RandomVector.

@codell In order to answer your Question "why this happens", I need an example of "this", the phenomenon in question. I don't know how to make up such an example myself. If you can make a smaller example of "a particular type of system", great; if not, I can work with the quadratics in 16 variables. And please point out with a comment:

  1. "a particular variable free"
  2. "where this variable is the root of a polynomial"

I'm also curious whether using eliminate instead of solve will correct this problem. Simply replace solve with eliminate; the argument syntax is the same:

eliminate({equations}, {variables that you don't want to be free});

Please post an example in Maple code, the need for which should've been obvious.

First 370 371 372 373 374 375 376 Last Page 372 of 709