Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

Please confirm via an attached worksheet that your Maple gives you a general solution. My Maple 16 doesn't.

@vv I've not been able to do it. Have you?

@moses Thank you, Moses. The acknowledgement is much appreciated.

@AndrewG I'll have to research that. I had never heard of c-means or k-means clustering until you mentioned it above. My entire knowledge of it consists of the two websites I cite in the code and the Matlab help page that you cited. Please provide a link to the post to which you refer. I'll be happy to code in Maple any useful algorithm that I can find sufficient references for.

@Markiyan Hirnyk With your correction, I give it a vote up. It should be noted, however, that in the case where X and Y are independent with variance 1, the above code generates the same thing as did the OP's original suggestion.

@tomleslie The plain map recreates it once; in other words, it creates an output Array and leaves the input Array intact. If you use map[inplace], then the input is replaced with the output; in other words, itself becomes the output, and there's no need to assign the result with :=. The inplace option is only available for rtables.

Regarding which is better practice, I'd say, in general, the list. Lists are more convenient for a variety of operations. Also, reading through the Maple library code, I don't recall many instances of a list being converted to an Array when a list operation would suffice.

@Markiyan Hirnyk 

The Wikipedia article that you cited says that the final step to generate a sample point is mu + A.z. Your code is doing, essentially, z + mu + A.z.

@tomleslie It is only repeatedly recreating the list that is inefficient. Kitonum's first solution, using map, only recreates it once.

@Oak Staff It would take me writing a book to explain things at the level that you need. I suggest that you start with a beginner's book on computer programming in Python. Pay particular attention to any material dealing with procedures, functions, or recursion. IMO, Python is the freely available language that is most like Maple. Then read the Maple help pages such as ?proc, ?Statistics,Tally, ?table, ?nops, ?add, ?remember, ?elementwise, ?thisproc, ?list, ?local, ?if, and ?indices. Then move on to the Maple Programming Guide. The whole book is available through Maple's onboard help system.

@Kitonum Your second method, the modification of the OP's code, involves recreating the whole list for each distinct negative entry. That'll be quite inefficient for a long list.

@adel-00 I only translated the code. I don't have any overall understanding of it.

@adel-00 Yes, I can translate this into Maple. It'll be a few hours though.

I've copied the original Question here so that you can't erase it:

I'm trying to write a procedure that computes Pollard's P-1 Method for a given integer n, and then outputs the prime factorisation of n.

Here is what I have so far:

Pollard := proc (n)
local i, r, g;
r[1] := `mod`(2^factorial(2), n);
for i from 2 while gcd(`mod`(r[i-1]-1, n), n) = 1 do
r[i] := `mod`(2^factorial(i+1), n) end do;
g[i] := gcd(`mod`(r[i-1]-1, n), n);
if g[i] < n then return g[i]
else return n
end if
end proc;

But my procedure doesn't seem to work for a lot of large values for n.
And also I can't figure out how to make it actually output the factorisation.

Any help would be appreciated.

Now you've deleted your responses!! That's almost as bad!

Thank you for restoring the Question and thus restoring my faith in humanity. If you now post the queue question, I'll answer it forthwith.

First 430 431 432 433 434 435 436 Last Page 432 of 709