Random number generator with conditions

I am using this right here to generate random coordinates.

r = randomGenerator()

a = r.int(-10,10)
b = r.int(-10,10)
c = r.int(-10,10)
d = r.int(-10,10)
e = r.int(-10,10)

a2 = r.int(-10,10)
b2 = r.int(-10,10)
c2 = r.int(-10,10)
d2 = r.int(-10,10)
e2 = r.int(-10,10)

Is there a way to tweak this so that each variable will not generate the same number as any other variable? I am trying to eliminate the possibility of duplicates.

Pretty sure I’ve done this in CL, but it was extremely unwieldy for even just a few variables. I think it would be much easier using lists in a graph. I know they’ve added new stuff for using lists. Essentially, start with a list L1=[-10,…10]. Select a random element from that list. Create new list with that removed. Select random from that list, etc. I know there were already ways to do this, but I’m thinking there are simpler methods now.

On the topic, would you know how to get this to work?

r = randomGenerator()

a = r.int(-10,10)

b = r.int(-10,10)
c = simpleFunction(“a+b”)

content: "${a}, ${b}, ${c}"

trying to set up a self created arithmetic list. Where “a” and the common difference, “b”, are created and the next number is generated by adding “a” and the “b” together. I would use this same idea to create more numbers in the list, but was just trying to get it to work first.

simpleFunction defaults to a function in terms of x. Anything else you need to specify using additional parameters:

c = simpleFunction("a+b", "a" , "b")

but to have a value output for c, you also need to evaluateAt and instead I’d use:

c = numericValue("{$a} +${b}")

1 Like

That was it! I can’t thank you enough for all the help you give!

The way I’d do it now is to create list of intervals, sum from a lower bound, and then randomize it:

https://www.desmos.com/calculator/fxbkjlmdmm

The new list functionalities are pretty great. I love that I can use a list as a bounds for a sum over a list.

where is the y value being derived from?

Sorry for the delayed response - the y values just increasing by a constant value for each point in the sequence - the first point is the lowest in the random sequence, and the last is the highest. The x values are the randomly generated values, evenly distributed with no repetition.

1 Like