Carl Love

Carl Love

28070 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@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.

Please don't change a Question after it has been Answered, ever. Instead, post a new Question. Changing the Question makes the already-posted Answer look like nonsense, which is extremely disrespectful to the person who wrote the Answer.

@jacksonmeg To avoid the RootOfs, you need to use option explicit, as shown by Kitonum.

@brownr Yes, that's essentially correct. Vote up. The only quibble that I have is with the word "kernel". It should be replaced with "default" or "non-package" or "global". The default int isn't a kernel command because it's written in Maple.

There are a great many Posts and Questions that have disappeared, and even more Answers and Replies are missing although their Questions and Posts remain. It has been reported here many times. I doubt that it has anything to do with spam filtering.

I wonder if there's a record of when things were deleted.

@jcrook Please carefully reread my first reponse titled "Problem with theta range." It explains precisely why your answers are double the correct answers.

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