randpoly problem...

Hi all I am attempting to use the randpoly feature to generate a random polynomial of 1st degree with non-zero coeffs between -2 and 2.

I have tried the following:

factor1 := randpoly(x, dense, degree = 1, coeffs = rand(-2 .. 2))

unfortunately as you will find quite often this produces the polynomial "0".  Which it is very clear this is not wanted.

Any ideas would be appreciated.

Thanks,

Mark

help with random numbers in sequence...

I am trying to construct a random set of angles measured in degrees with pairs that are the equivalent in radians.  for example [0,0],[90,Pi/2],[-30,-Pi/6],etc...  but completely random.

so far I have the following:

restart;
randomize();
a := rand(-90 .. 90);
seq([a(i), convert(a(i)*degrees, radians)], i = 1 .. 4);

the trouble is it appars it is randomizing a both times it is called in the sequence.  I would like to have it randomize for each iteration in the sequence.

strange old rand() behavior in Maple...

http://www.maplesoft.com/applications/view.aspx?SID=1526&view=html

near the middle, it says

I just tried in Maple 2016 and that is not what it did. It says this was in Maple 8. It seems this was "fixed" in Maple 2015.

My question: How could Maple 8 have simplified rand()/rand() to 1 before evaluating rand()?  i.e. why was not rand() evaluated first, before the simplification was made? it seems to have worked as if one typed x/x , but rand() would have been a function, and it should be evaluated before?

Just wondering why Maple 8 did the above, that is all.

Generate random NEGATIVE numbers...

How do I genereate random negative numbers?

when i put a minus sign in the rand-function i get an error.

I need to for example generate a random number between -r and r, where r is the input

Computing velocity and position with a random vari...

If a particle that moves in only one dimension is subject to a force Fi between the time

steps ti and ti+1, the velocity vi and position xi of the particle is:

v[i] := v[i − 1] +(1/m)*F[i]*Δt

x[i] := x[i − 1] + 0.5 (v[i − 1] + v[i])

Use the mean of v between ti and ti+1 when updating xi, since the value may change

a lot from step to step. In the subsequent, we set the mass m = 1 and the time steps

are Δt = 1, since we could absorb m and Δt in the expression for the force Fi anyway.

Write a procedure that computes xi and vi for a particle subject to random forces Fi,

uniformly distributed on the interval [-0.5..0.5].

I`ve written a procedure that generates random forces (F[i]) in the given interval. How can I write a for – procedure that computes xi and vi ?

How do I generate random number between -x and +x?...

Hi

I need help to write a procedure that uses Maple`s built-in rand() - function to generate uniform random floating point numbers between -r and r, where r is an input parameter of the procedure.

>M:=600;

>R1:=rand(0..1):   R2:=() -> 2*R1()-1:
>for i from 1 to M do
f[i]:=R2()*rand()/10.^12:
end do:

With this procedure I get random floating point numbers (+/-), but I can`t figure out how to generate numbers between +/- a parameter (in this case r).

If anyone could help me understand how to get this to work I would be very gratefull.

Random walk problem...

I have made an algorithm for producing random walks (only possible to walk one step to either direction except downwards(EDIT: It is possible to go downwards, but it has to be when making a turn to the right or left). The walks are determined by the rand function:

R3:=rand(1..3): (1: go straight on; 2: turn right; 3: turn left)
M:=15; N:=1500;

Randwalk3:=proc(R3)
local i,j,r,X,Y,L;
for j from 1 to M do
X[0,j]:=0;                                # Initialization
Y[0,j]:=0;
X[1,j]:=1;                                # The first step should still be taken to the point (1,0)
Y[1,j]:=0;
for i from 2 to N do
r:=R3();
if r=1 then X[i,j]:=2*X[i-1,j]-X[i-2,j]; Y[i,j]:=2*Y[i-1,j]-Y[i-2,j];                   # go straight on
elif r=2 then X[i,j]:=X[i-1,j]+Y[i-1,j]-Y[i-2,j]; Y[i,j]:=Y[i-1,j]-X[i-1,j]+X[i-2,j];    # turn right
else X[i,j]:=X[i-1,j]-Y[i-1,j]+Y[i-2,j]; Y[i,j]:=Y[i-1,j]+X[i-1,j]-X[i-2,j];             # turn left
end if;
if (X[i,j]=X[j,j] and Y[i,j]=Y[j,j]) then L[j]:=i; break; end if; (This is wrong)
end do;
end do:
return [X,Y,L];
end proc:

The question from is like this:
Modify the algorithm such that it stops at r[i] if r[i] = r[j] for any 0 <= j <= i-2. r=(xi,yi). M is the number of random walks and N is the number of steps. The length of the paths should be stored in L[m] (m=1..M). How do I implement the if-test correctly?

Sampling from multivariate probability distributio...

Hi All,

I have a fucntion f(x,y,z) = exp(-x^2 -y^2 - z^4) and would like to plot the probabity density in real space. One method would be to randomly sample points in a grid based on f(x,y,z). The function f(x,y,z) is clearly peaked around x=y=z=0, so you would expect many points to lie around there. So the plot would look like a clump near (0,0,0) which gets less dense away from (0,0,0).

In the worksheet below, I sampled points from the Uniform distribution to file in the 3d-plot. I would like these points to be sampled from f instead, but am not sure how to do this.

Any help is appreciated,

 > restart;
 > with(Statistics):
 > R := 10; # x-axis size N := 100; # Number f points to sample
 (1)
 > # Unnormalized Probability distrubution f := (x,y,z) -> exp(-x^2 -y^2 - z^2);
 (2)
 > # Clearly f is peaked at (0,0,0) and decays. Therefore I want a plot a lot of points near (0,0,0), and fewer points away from (0,0,0) plot3d(f(x,y,0), x = -1..1, y = -1..1);
 > X := Sample(Uniform(-R, R), N):
 > Y := Sample(Uniform(-R, R), N): Z := Sample(Uniform(-R, R), N): XYZ := Matrix([[X], [Y], [Z]])^%T;
 (3)
 > ScatterPlot3D(XYZ, color = blue, symbolsize = 20);
 >
 >
 >
 >

Random initial function for pdsolve...

Hi everybody,

I would like to define a function with random values to be used in pdsolve (numeric) as a initial condition.

Any help?

Thanks,

Javier

List of random colors...

Dear Community,

How could I specify a list of random colors using some kind of an RGB function, which then could be used in another command for coloring? I think of something like this:

myColors := [ seq( RGB ( [rint(0,255) , rint(0,255) , rint(0,255)] ) , j = 1 .. 20 ) ] :

which does not work of course :-)  This should produce me a list of 20 random colors.  What would be the right RGB color function?

Tx for the kind help in advance

best regards

Andras

Generation of a random array...

To gererate a random initail cofigration -1 or 1

spin = (-1).^(round(rand(N)));

for i=1:1000,

neighbours = circshift(spin, [ 0 1]) + ...

circshift(spin, [ 0 -1]) + ...

circshift(spin, [ 1 0]) + ...

circshift(spin, [-1 0]);

how to do this in maple?

Is Ising a package?...

Hi all

Is Ising a package?

for i = 1:12000

%while (1),

% Choose a random value between 0 and 1 for the interaction strength

J = rand()+1e-10;

% Perform a simulation

[M, N, E] = ising2(n_grid, J);

% Records the results

Ms = [Ms M/(n_grid^2)];

Es = [Es E/(n_grid^2)];

Ns = [Ns N];

Js = [Js J];

i = i+1;

Generate suitable random integer ...

Coding in key generation of RSA Cryptosystem

message :=123456;

u := nextprime(RandomTools[Generate](integer(range = 10^100 .. 10^(110-1))));

v := nextprime(RandomTools[Generate](integer(range = 10^100 .. 10^(110-1))));

N := u*v;

phi := (u-1)*(v-1);

In RSA cryptosystem, the encryption or decryption of message only can be existed between range 1<=message<=N. This means that if the value of message bigger than N value then we can't get back the original value when performing decryption.Thus, wanna to ask that how can we create a coding so that the system will recognise the random integer u and v whether lie between range 1<=message<=N, means wanna crete a coding that if  N>=message then it will continue to the phi step whereas if message>=then the system need to regenerate the u and v until it satisfy the condition  1<=message<=N .Thus please help as i am a beginner in Maple.Thanks.

Random flipped bit ...

May I know any command can help to random selected a position in a group of bit number then flip that number but with condition after convert to bytes the number cannot be more than 7?

For example,

I have integer 3, i convert to binary become 0000011

then i need a command to random select a position to flip and only one bit can be flipped.

After that the group of flipped number will convert back to decimal, but total value cannot more than 7? any command can solve?  Thank you.