I’ve got a list of numbers in the Graph.
I’m trying to randomly pull a number from the list.
My goal is to be able to adjust the list A_L. Therefore, I’ve created A_C to count the length of the list. So A_C is always an integer. A_P is randomly choosing a position in the list and then I end up with the value A_V that I’ll actually use for the process.
A_C works correctly on finding the length, but the random piece is returning NaN.
I’m wondering if my errors are caused because CL needs to know (force) the fact that A_C is always an integer?
Graph CL area:
I think you can only put numbers (not sources or variables) into the bounds for the random generator.
In any case, here’s an example that might work for you. The probabilities might not be perfect but they’re pretty good. The max is built into the expression to make the index 1 when r=0 (the probability of which is very small, like 10^-15 small or something). Other than making r=0 index 1, the probabilities should hold.
graph script: r = randomGenerator() number("r"): r.float(0.00000000000001,1)
Not being able to put variables in the random generator would explain why I get the error.
(But just to check my CL code understanding, if the variable was allowable there, I had it right?)
(This code is being used in an extension of your equation solver activity.)
Eric: Oh! Good to know!
Jay: Your new coding that you recommended (along with the graph stuff) doesn’t redo the randomizer when I press the button. Oops, had to add the submit count back into the random generator.
After looking at Eric & Jay’s suggestions & links, I think my error was that in an earlier rendition, I included a slider for a value that now no longer likes having the slider. I guess when you create a slider for a number variable, that’s fine CL overwrites it. But if the slider is tied to a value in a list, then no can do…complaint (it tells me I defined it too many times).
Seems to be working now as intended.
So here’s the latest rendition. Using Jay’s randomizer inside the graph, although my original (with the fix about sliders) and Eric’s methods work also!
The red points were to test the values and can be deleted.
Our next hope is to randomize a symbol for the equation/inequality: <, <=, =, >=, >
You can randomize symbols or pictures (whatever you want) by using a restricted domain. Say your random variable is “Q” and Q controls the inequality symbol which is at the point (0,1). Q is a random value from 1 to 5
Then write five corresponding points where one of the coordinates has a restricted domain
Hey @HumanizedMath. Your random gen is amazing. I was wondering if there would be a way to make it generate just either 2 or 3 cards at the most. I was looking from all the CL and I def couldn’t figure it out. The more i tried to edit the CL, the more I kept getting confused.
There are some newer list functions that might help. You could have a list 1-52 to designate which cards. There is a shuffle function. You can use brackets after the name of a list to designate which items to select form it.
D=shuffle[1...52] #a shuffled deck
C=D[1...3] #take the first three elements (cards) of list D
D_1=D[4...52] #the remaining deck
I think a lot of these functions weren’t available when @HumanizedMath did his impressive coding.