Search In
• More options...
Find results that contain...
Find results in...

Member

5

## Awards

This user doesn't have any awards

• Title
Newbie

## Recent Profile Visitors

120 profile views

1. ## Does individual RAM stick capacity matter?

I'm upgrading my Intel 5820k PC from running single channel 8GB DDR4 to 16GB and I wanted to take advantage of using quad-channel, but to do that I would have to run 4x4GB sticks. The kit I'll be purchasing will also be faster (2666 from 2400) but I was wondering if the individual stick size going from 8GB's to 4GB's would matter? I don't think so, but I'm only 90% sure and was wondering if you guys could help me out.
2. ## What Makes a Good PRNG/TRNG Algorithm?

I appreciate all the comments and the resources you have provided; I'll be sure to look through all of them. Thank you.
3. ## What Makes a Good PRNG/TRNG Algorithm?

So I was making a random number generator in C++ and I decided to do something like this: #include <iostream> #include <chrono> // for timer operations #include <cmath> // for pow() using namespace std; class Timer { private: using clock_t = chrono::high_resolution_clock; using second_t = chrono::duration<double, ratio<1> >; chrono::time_point<clock_t> m_beg; public: Timer() : m_beg(clock_t::now()) { } double elapsed() const { return chrono::duration_cast<second_t>(clock_t::now() - m_beg).count(); } }; int main() { Timer t; int time_seed = t.elapsed() * pow(10, 7); // Time in hundredths of nanoseconds time_seed = time_seed % 10; // Number is based off nanosecond value cout << time_seed << endl; return 0; } Big thanks to Alex at https://www.learncpp.com/cpp-tutorial/8-16-timing-your-code/ for the timer. Effectively this program can output a double value representative of the timestamp at which it was called. The timer starts when the program begins and the value outputted is how long it took to get there. Running this on a laptop with Visual Studio 2019 I can go far as e-7 digits back (the equivalent of 100's of nanoseconds or 1/10,000,000 of a second). The "randomness" is derived from two factors: the speed of the computer and the human element at which the user performs an action (in this case, running the program). Now this performs much better when there is a more extensive action or calculation done prior, such as performing a Fibonacci sequence or something of the like, but my point being that you could feasibly create a TRNG algorithm using a mix of a timer and some human interaction with the program. So I tried a few things; I compared the TRNG algorithm above with the rand() PRNG function found in the <cstdlib> library and built a calculator to determine bias. There are three tests between the two, all of which seek to create a thousand "random" numbers: one test will generate a thousand numbers between 0-9, the second test will take those one thousand numbers and convert them to a binary value 0 or 1, and the third test will convert a thousand numbers into binary and then XOR those values. Each of these tests will measure, and output, a bias value that's determined by the sum of each individual integers absolute value difference between it's outputted count vs expected count (if the number 9 is outputted 97 times when it's supposed to be outputted 100 times then the bias is 3). Here is what I made: #include <iostream> #include <chrono> // for timer operations #include <cstdlib> // rand() function #include <cstdarg> // bias calculators #include <cmath> // pow() function using namespace std; class Timer { private: using clock_t = chrono::high_resolution_clock; using second_t = chrono::duration<double, ratio<1> >; chrono::time_point<clock_t> m_beg; public: Timer() : m_beg(clock_t::now()) { } double elapsed() const { return chrono::duration_cast<second_t>(clock_t::now() - m_beg).count(); } }; int bias_calc(int num_value, ...) { int bias_sum(0); va_list num_values; va_start(num_values, num_value); for (int it(0); it < num_value; it++) { bias_sum += abs(100 - va_arg(num_values, int)); } va_end(num_values); return bias_sum; } int binary_bias_calc(int num_value, ...) { int bias_sum(0); va_list num_values; va_start(num_values, num_value); for (int it(0); it < num_value; it++) { bias_sum += abs(500 - va_arg(num_values, int)); } va_end(num_values); return bias_sum; } int main() { Timer t; int num1(0), num2(0), num3(0), num4(0), num5(0), num6(0), num7(0), num8(0), num9(0), num0(0); for (int it(0); it < 1001; it++) // 1000 iterations { int num_cache = rand() % 10; // random number 0-9 if (num_cache == 0) ++num0; else if (num_cache == 1) ++num1; else if (num_cache == 2) ++num2; else if (num_cache == 3) ++num3; else if (num_cache == 4) ++num4; else if (num_cache == 5) ++num5; else if (num_cache == 6) ++num6; else if (num_cache == 7) ++num7; else if (num_cache == 8) ++num8; else if (num_cache == 9) ++num9; } int num1_time(0), num2_time(0), num3_time(0), num4_time(0), num5_time(0), num6_time(0), num7_time(0), num8_time(0), num9_time(0), num0_time(0); for (int it(0); it < 1001; it++) { int time_seed = t.elapsed() * pow(10, 7); // Time in hundredths of nanoseconds time_seed = time_seed % 10; int num_cache = time_seed; // Numbers are based directly off nanosecond value if (num_cache == 0) ++num0_time; else if (num_cache == 1) ++num1_time; else if (num_cache == 2) ++num2_time; else if (num_cache == 3) ++num3_time; else if (num_cache == 4) ++num4_time; else if (num_cache == 5) ++num5_time; else if (num_cache == 6) ++num6_time; else if (num_cache == 7) ++num7_time; else if (num_cache == 8) ++num8_time; else if (num_cache == 9) ++num9_time; } int bin_num0(0), bin_num1(0); for (int it(0); it < 1001; it++) // 1000 iterations { int num_cache = rand() % 10; // random number 0-9 if (num_cache % 2 == 0) ++bin_num0; else if (num_cache % 2 == 1) ++bin_num1; } int bin_num0_time(0), bin_num1_time(0); for (int it(0); it < 1001; it++) // 1000 iterations { int time_seed = t.elapsed() * pow(10, 7); // Time in hundredths of nanoseconds time_seed = time_seed % 10; int num_cache = time_seed; // Numbers are based directly off nanosecond value if (num_cache % 2 == 0) ++bin_num0_time; else if (num_cache % 2 == 1) ++bin_num1_time; } int xor_bin_num0(0), xor_bin_num1(0); for (int it(0); it < 1001; it++) { int num_cache = rand() % 10; // random number 0-9 num_cache = num_cache % 2; // Converts to its last binary digit int num_cache_2 = rand() % 10; num_cache_2 = num_cache_2 % 2; int bin_check = num_cache + num_cache_2; // Four outcomes: 00 01 10 11 if (bin_check == 0) ++xor_bin_num0; // 00 else if (bin_check == 2) ++xor_bin_num0; // 11 else if (bin_check == 1) ++xor_bin_num1; // 01 10 } int xor_bin_num0_time(0), xor_bin_num1_time(0); for (int it(0); it < 1001; it++) { int time_seed = t.elapsed() * pow(10, 7); time_seed = time_seed % 2; int num_cache = time_seed; int time_seed_2 = t.elapsed() * pow(10, 7); time_seed_2 = time_seed_2 % 2; int num_cache_2 = time_seed_2; int xor_bin_check = num_cache + num_cache_2; if (xor_bin_check == 0) xor_bin_num0_time++; // 00 else if (xor_bin_check == 2) xor_bin_num0_time++; // 11 else if (xor_bin_check == 1) xor_bin_num1_time++; // 01 10 } cout << "|C++ PRNG| |Nanosecond| |C++ Binary| |Nano Binary| |C++ XOR Binary| |Nano XOR Binary|" << endl; cout << "num0 " << num0 << " " << num0_time << " " << bin_num0 << " " << bin_num0_time << " " << xor_bin_num0 << " " << xor_bin_num0_time << endl; cout << "num1 " << num1 << " " << num1_time << " " << bin_num1 << " " << bin_num1_time << " " << xor_bin_num1 << " " << xor_bin_num1_time << endl; cout << "num2 " << num2 << " " << num2_time << endl; cout << "num3 " << num3 << " " << num3_time << endl; cout << "num4 " << num4 << " " << num4_time << endl; cout << "num5 " << num5 << " " << num5_time << endl; cout << "num6 " << num6 << " " << num6_time << endl; cout << "num7 " << num7 << " " << num7_time << endl; cout << "num8 " << num8 << " " << num8_time << endl; cout << "num9 " << num9 << " " << num9_time << endl; cout << "C++ Bias: " << bias_calc(10, num0, num1, num2, num3, num4, num5, num6, num7, num8, num9) << endl; cout << "Nanosecond Bias: " << bias_calc(10, num0_time, num1_time, num2_time, num3_time, num4_time, num5_time, num6_time, num7_time, num8_time, num9_time) << endl; cout << "Binary C++ Bias: " << binary_bias_calc(2, bin_num0, bin_num1) << endl; cout << "Binary Nanosecond Bias: " << binary_bias_calc(2, bin_num0_time, bin_num1_time) << endl; cout << "XOR Binary C++ Bias: " << binary_bias_calc(2, xor_bin_num0, xor_bin_num1) << endl; cout << "XOR Binary Nanosecond Bias: " << binary_bias_calc(2, xor_bin_num0_time, xor_bin_num1_time) << endl; return 0; } And so feel free to run this program on your own compiler but I feel showing this program above is necessary for the argument I'm presenting. The PRNG algorithm provided by C++ will output the same values every single time, so long as the seed value stays the same or there are no changes to the code impacting it's calculations. The TRNG algorithm provided by the timer however, will never output the same numbers. The Nanosecond Bias won't always be lower than the C++ Bias, but many times it will be. When this is the case, I can not say. I could add a loop, make it so that if I perform a test and it's bias is higher than the C++ bias (which in this case is basically a constant value) then to simply rerun until that is no longer the case, but that's not really the point of having this kind of tool in a program. So here's my question: when is it a good time to use a PRNG algorithm vs a TRNG, and vise versa. Is there a way I could improve my program above, and is the combination of a high tick clock and the human element a good means of generating random values?
4. ## Can you reduce cellphone heat with graphite?

Basically what I'm wondering is if placing a graphite pad (here's a link to one: https://www.newegg.com/innovation-cooling-ic-graphite-thermal-pad-40/p/2MB-000J-00003?Description=graphite pad&amp;cm_re=graphite_pad-_-2MB-000J-00003-_-Product ) under/over a cellphone battery would reduce the heat felt on the palm. I know having personal experience with a Galaxy S5 for over five years now (I've replaced the battery I think twice now, not because of heat issues) that Samsung phones do get really hot and palm sweat seems more of an inconvenience. I have a graphite pad lying around and was wondering if applying it would be safe or noticeable.