Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 359 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

Your 25%-75% x 100x algorithm sounds very strange to me. Do you have a reference for it, or did you just make it up? Is there something unusual about this dataset?

@Hassan Alkomy Your work is okay. It wasn't clear in your original Question that FyjR is an expression that depends on j. From what you've shown, it appears to be a simple variable name. If it depends on j, everything is fine with the sums.

Please re-enter both your original expression for Gc and your desired simplified form with all multiplications explicitly specified.

Also, you say that ab, and are to be determined by Maple, yet b (definitely) and (possibly) appear in the original Gc, so it doesn't make sense to me to "determine" them. So please clarify that. 

I think that the fastest code to calculate an arbitrary position[*1] in the Fibonacci sequence is also the briefest:

F:= n-> (<1,1;1,0>^(n-1))[1,1];

(For the OP: <1,1;1,0> is the 2x2 matrix

1  1
0  1,

and the [1,1] selects the row 1, column 1 entry.)

I believe that the TI-84 handles small-matrix arithmetic. You may need to make a free download from TI to get a matrix upgrade.

A similar matrix method can be constructed for any linear recurrence with constant coefficients (regardless of order).

[*1]Direct application of the recurrence is probably fastest for generating an entire initial segment of the sequence.

 

@radaar So, nothing at all happens when you enter the read command at the prompt, then press Enter? You don't even get a new prompt? What happens if you enter 2+2;? What about sin(Pi);?

@Kitonum The OP means that given a positive rational number u, find rational numbers abc, such that u = a*b/2 and a^2 + b^2 = c^2.

@radaar Assuming that the file contains commands that would ordinarily display output (e.g., they end with semicolon), it should appear immediately on your screen.

@Teep Sorry, since I couldn't copy-and-paste the code from your PDF, I didn't realize that your graph had "loops" (corresponding to the positions on the diagonal of the adjacency matrix that are nonzero). The GraphTheory package (as well as a large part of the mathematical theory of graphs) doesn't deal with that case. But here's a workaround for you that I think will suit your purposes: We can highlight the vertices that are supposed to have loops, like this:

restart
:
n:= 12 #number of vertices
:
#The next 3 lines are just me duplicating the Matrix from your PDF. 
#You don't need to do these.
A:= Matrix(n$2):
A[7]:= <1,1,0,0,0,0,1,1,0,1,0,0>:
A[9]:= <0,0,1,1,1,1,0,0,1,0,1,1>:

#Once your dimension n is set and your adjacency Matrix A defined, do this:
Loops:= select(k-> A[k,k] <> 0, [$1..n]);
A[Loops$2]:= 0:
GT:= GraphTheory:
G:= GT:-Graph(A):
GT:-HighlightVertex(G, Loops, "Magenta");
GT:-DrawGraph(G);

Please post the exact command line that you used and what the system's response was.

Also, please give the details surrounding "Maple GUI version hang most of the time." The vast majority of users use Maple's GUI version, and while it may hang occasionally, it's certainly not "most of the time" for most of them.

If you make any sincere attempt to write some code to solve this, we will help you. Indeed, I've already written a complete answer.

@Joe Riel The typespec 'rtable'(..) will select for one-dimensional rtables. There is a type operator, but it's pretty much worthless. It amounts to "procedure declared explicitly or implicitly with option operator." So `<` isn't an operator.

@Joe Riel Here's my version of the bubble sort, allowing for inplace operation if the input is an rtable, and user-specified ordering function. These two features seemed trivial to include, so I did.

BubbleSortRT:= proc(L::{list, rtable}, `&<`:= `<`, {inplace::truefalse:= false})
local 
   R:= `if`(inplace implies L::list, rtable(L), L),
   n:= rtable_num_elems(R, 'All'), k, m
;
   for k to n-1 do
      for m to n-k do
         if R(m+1) &< R(m) then (R(m),R(m+1)):= (R(m+1),R(m)) fi
      od
   od;
   `if`(L::list, [seq(R)], R)
end proc
:

 

@mmcdara Your (sub-)formula

Statistics:-Quantile~(Normal(0,1), Statistics:-Sample(Uniform(1/2, 1), N))^~2

is equivalent to the much faster code

Statistics:-Sample('Normal'(0,1), N)^~2

 

@mmcdara The Iterator:-CartesianProduct can be easily replaced with any of numerous short Cartesian product procedures. I recently posted four completely different such procedures in the thread "Combining lists".

Maple 2018 introduced embedded assignment: Assignment statements can now appear anywhere inside expressions. The statement in question says that the probability of any value of the new r.v. is the sum of the probabilities of all tuples that generate that value, and the probability of any tuple is the product of the probabilities of its elements (due to independence).

Here's code that should work in Maple 2015:

CartProd_NestedSeq:= proc(V::seq({Vector, list}))
local i,k,S;
   eval(subs(S= seq, [foldl(S, [seq(i[k], k= 1..nargs)], seq(i[k]= V[k], k= 1..nargs))]))
end proc
:
CombineDiscrete:= proc(R::list(RandomVariable), f)
uses S= Statistics, It= Iterator;
local 
   r, X, t, P:= table(sparse), nR:= nops(R), fX,
   Pr:= proc(e::(RandomVariable=realcons)) option remember; S:-Probability(e) end proc
;
   for X in 
      CartProd_NestedSeq(
         seq([solve~(op~(indets(S:-PDF(r,t), specfunc(Dirac))), t)[]], r= R)
      )
   do
      fX:= f(X[]);
      P[fX]:= P[fX] + mul(Pr(R[r]=X[r]), r= 1..nR)
   od;
   P:= [entries(P, 'pairs')];
   S:-RandomVariable(EmpiricalDistribution(lhs~(P), 'probabilities'= rhs~(P)))
end proc
:  

 

@erik10 Yes, there is a simple command in Statistics for computing (discrete) sample frequencies: Tally. For samples from continuous distributions, TallyInto is more appropriate.

First 281 282 283 284 285 286 287 Last Page 283 of 709