mardi 1 octobre 2019

What is the recommended character count per line for files containing random data?

I'm building a system to store data from QRNGs to be used at a later point. obviously, you don't want a 500MB file with one single line - unless you do. I'm kinda new to this specific use-case. I don't know, would it be ok to store it all in one line if I'd be using the random data as needed ... maybe streaming it? Each use will depend on what probabilities need to be assessed. So, one use might need 7 bits, then next might need a few thousand. But no matter what the need is, whatever I use will have to be discarded and removed from the file. (not sure if that has bearing here). Sorry - rambling. Is there a recommended character count per line? Is it ok to store it all in one line? Are there industry standards concerning this? I don't even know where to look. Google just brought up a bunch of arbitrary links that really don't have anything to do with my use case.




Does boost:: or std::normal_distribution use inverse cumulative distribution function?

The specification for my project asks to produce normally distribute random numbers, and it specifically requires that I use inverse cumulative distribution function to convert uniformly distributed numbers to the standard normal ones.

The reason for this requirement: an older "polar" method exists, where a pair of uniformly distributed random numbers is converted to a pair of normally distributed numbers, which also involves throwing away the original numbers in some cases. This older method is known to produce imperfect distribution tails.

I want to use either std::normal_distribution or boost::normal_distribution, combined with corresponding random number engine. Is there a guarantee in C++ standard that precludes using polar method? If not, I'd like to know for sure that Visual C++ 14 or boost uses the modern method (inverse cumulative normal distribution).




Solidity - Generate unpredictable random number that does not depend on input

I know that the "how to generate random number" in solidity is a very common question. However, after reading the far majority on answers I did not find one to fit my case.

A short description of what I want to do is: I have a list of objects that each have a unique id, a number. I need to produce a list that contains 25% of those objects, randomly selected each time the function is called. The person calling the function cannot be depended on to provide input that will somehow influence predictably the resulting list.

The only answer I found that gives a secure random number was Here. However, it depends on input coming from the participants and it is meant to address a gambling scenario. I cannot use it in my implementation.

All other cases mention that the number generated is going to be predictable, and even some of those depend on a singular input to produce a single random number. Once again, does not help me.

Summarising, I need a function that will give me multiple, non-predictable, random numbers.

Thanks for any help.




Exclude a particular character from being generated by random.choice()

I am trying to generate random characters using random.choice(string.ascii_lowercase). I do not want to include all the lowercase characters in the random.choice(). I want to exclude some

import random 
import string

random.choice(string.ascii_lowercase)

choice to select from 'abcdefghijklmnopqrstuvwxyz' exclude 'abd' from the choice generated by the random function




Javascript code - Generate random text from seperate word buckets based on drop down list inner text

`

var e = document.getElementById("select_list");
var textselected= e.options[e.selectedIndex].text;

var Select1 = [ "Text1", "Text2", "Text3", ];

var Select2 = [ "Text1", "Text2", "Text3", ];

var Select3 = [ "Text1", "Text2", "Text3", ];

$("#click-button").click(function() {

if (textselected.includes('textselected1')) {
$("#quote-box p").html(Select1[Math.floor(Math.random()*Select1.length)]);

} else if (textselected.includes('textselected2')) {
$("#quote-box p").html(Select2[Math.floor(Math.random()*Select2.length)]);

} else if (textselected.includes('textselected3')) {
$("#quote-box p").html(Select3[Math.floor(Math.random()*Select3.length)]);

} });

`

I have a drop down list in website with ID = 'select_list' Basically when user selecting something then the selection inner text will need to be used as a criteria for random text qoutes.

I have three items in drop down list named: textselected1, textselected2, textselected3

If user selected 'textselected1' then when button clicked random text will be generated in 'quote-box' from random text list 'Select1'

If user selected 'textselected2' then same button clicked but random text will be generated in 'quote-box' will be from random text list 'Select2' etc..

Please need some help with the code as I started to write something but it doesnt work.

Any help will be much apprieciated.




How to use optional argument of random.shuffle in Python

From the doc of random.shuffle(x[, random]), it says:

The optional argument random is a 0-argument function returning a random float in [0.0, 1.0); by default, this is the function random()

Could someone please explain what 0-argument function means and give an example of random.shuffle() with the optional argument random? I searched but couldn't find any example for that case. Also, what did it mean by this is the function random()? Does this refer to the optional argument?

Thank you.




Updating a lot of rows with random data in Mysql

I have a database with personal data that I want to anonymize with random names etc. Eg., the table person (id int, first_name varchar, last_name varchar, birth_date date). I also have a table with random names, eg. first_name (id int, value varchar). I know that this boils down to optimizing select * from ... order by rand() and I've read several StackOverflow questions on it (and http://jan.kneschke.de/projects/mysql/order-by-rand/), but this doesn't answer the question of updating with random data in bulk.

I've tried:

  1. (Initially) UPDATE _person me SET birth_date = (SELECT value FROM anonymizer.birth_date ORDER BY RAND() LIMIT 1) (...same for other columns). As there are multiple tables, anonymizing the whole DB was going for an hour when I interrupted it.
  2. (Currently) UPDATE _person me join anonymizer.first_name on anonymizer.first_name.id = round(rand() * (select max(id) from anonymizer.first_name)) SET first_name = anonymizer.first_name.value. This single query took 5 minutes (apart from other columns and tables).

I can prepare my fake data tables in any way (init with sequence numbers etc.). Is there a way to anonymize the DB efficiently?