Whenever I sample, I get the same results for a given temperature value. Is there a way to configure a random seed or another value that controls the output?
Try calling math.randomseed(os.time()) once at the start of the program.
Related
Been trying to get a random song "I'm using fruit placeholders for now" and it always returns Orange
and I can't seem to figure out why.
math.randomseed(os.time())
local songLists = {"Apple", "Orange", "Pineapple"}
local songValue = math.random(#songLists)
local songSelected = songLists[songValue]
print(tostring(songSelected))
Lua uses PRNG (pseudorandom number generator) to calculate random number.
math.randomseed(os.time()) initalizes formula with some sort of data current time (not the best decision). os.time() gives current time with prezision of 1s, it means if you execute this code in loop within part of second you will get the same seed number (if clock not changes). The best practice is to initialize random math.randomseed(...) once application is started and with better random data as process id, os.clock(), ...
Most likely your problem is math.randomseed(...) is executed many times with the same seed data in this code or may be in anothe part of application.
Is there an SPSS syntax that can help me suppress smaller values when displaying frequencies? I'm able to hide small values using cross-tabs, but when I use Frequencies command I'm not able to suppress or hide small values.
This is my current syntax: Is there another command to add in suppressing output less than 10? Thank you!
Frequencies variables = alcoholany
/Order=ANALYSIS.
As far as I know you can't get this through the frequencies command alone - you'll need to identify those cases first and filter them out before running it:
aggregate /out=* mode=add/break=alcoholany/Ncat=n.
compute filt=Ncat>=10.
filter by filt.
Frequencies variables = alcoholany /Order=ANALYSIS.
filter off.
I have a function that is called three times in quick succession, and it needs to generate a pseudorandom integer between 1 and 6 on each pass. However I can't manage to get enough entropy out of the function.
I've tried seeding math.randomseed() with all of the following, but there's never enough variation to affect the outcome.
os.time()
tonumber(tostring(os.time()):reverse():sub(1,6))
socket.gettime() * 1000
I've also tried this snippet, but every time my application runs, it generates the same pattern of numbers in the same order. I need different(ish) numbers every time my application runs.
Any suggestions?
Bah, I needed another zero when multiplying socket.gettime(). Multiplied by 10000 there is sufficient distance between the numbers to give me a good enough seed.
I am trying to implement a 1D DCT type II filter in Labview. The formula for this can be seen here
As you can see xk = the sum of a sum function involving an iteration of n.
As far as I know the nested for loop should handle the function with the shift registers keeping a running total of the output. My problem lies with the output the the matrix xk. There is either only one output to the matrix or each output over-writes the last output due to no indexig. trying to put the matrix inside the for loop results in an error between the shift register and the matrix:
You have connected two terminals of different types.
The source is a double and the sink is a 1D array of double
Anyone know how I can index the output to the array?
I believe this should work. Please check the math.
the inner for-loop will run either 8 times, or however many elements are in the array xn. LabVIEW uses whichever number is smaller to determine the iteration count. So if xn is empty, the for loop wont run at all. If it's 20, the for loop will run 8 times.
Regardless, the outer loop will always run 8 times, so xk will have 8 elements total.
Also, shift registers that do not initialize a value at the beginning of a for or while loop can cause problems, unless you mean to do that. The value stored in the shift register after running the first time could be a problem the second time you go to run it.
I am trying to get a random number of 0-20 like so
RandomRange(0, 20)
I know alot of software when using there built in function for random it will give the same random numbers each time the program is ran, thus not so random.. Does RandomRange act this way? I could not test as not near programming computer. If Answer is yes, then how can i get a Really Random number?
Thanks
http://www.delphibasics.co.uk/RTL.asp?Name=Random
http://www.delphibasics.co.uk/RTL.asp?Name=Randomize
The Randomize command will re-seed the random number generator based on the current time of day. With that, the only way you'll get the exact same sequence of "random" numbers is if you run the program at exactly the same time of day (usually measured down to fractions of a second for these kinds of purposes).
EDIT: You can also use RandSeed (http://www.delphibasics.co.uk/RTL.asp?Name=RandSeed) to select the seed yourself. This is useful if you want to test the same sequence multiple times, for debugging, or want to randomize based on some other seed than time of day.