# Questions tagged [random]

12699 questions

1

votes

0

answer

81

Views

### c++ async : how to shuffle a vector in multithread context?

Running a multithreaded program, I noticed that the program was running faster using 1 thread compared to 4 threads, despite the CPU having 4 cores.
After investigating, I found out that the issue appears only when shuffling something.
Below the minimal program I created to reproduce the problem:
#i...

0

votes

1

answer

18

Views

### Random Image Generator not finding image in directory

I'm working on a very simple webpage that contains just a button that generates a random image above it.
I've searched online but none of the answers seem to solve my problem.
I have a js code that seems to be working: it generates a random number but when I try to link the number to '.jpg' (That's...

1

votes

1

answer

608

Views

### How to interpret the output of H2O .predict method for random forest classification?

When I use the predict method on my trained model I get an output that is 1 row and 206 columns. it seems to have 206 values ranging in values from 0-1. This sort of makes sense as the model's output is categorical variable with values 0 and 1 as possible values. But I don't get the 206 values, as I...

1

votes

1

answer

713

Views

### Multiclass classification of text in R

I have build a random forest for multiclass text classification. The model returned an accuracy of 75 %. There are 6 labels, however out of the 6 classes, only 3 are classified and rest are not classified. I would really appreciate if anyone could let me know what went wrong.
Below are the steps i f...

1

votes

1

answer

1.2k

Views

### How to set sampsize for random-forest on unbalanced data

I want to build a species distribution model using random-forest:
My training data consists of 971 records of species presence (71)/absence (900) and three environmental variables at systematically sampled points (4*4m, random starting point).
Training data:
str(train)
'data.frame': 971 obs. of...

1

votes

1

answer

58

Views

### How does python pre-process the script and read files efficiently for fixed subset of large amount of images

I need to read a subset of files from a large number of files. To read the subset of the files, we will first provide a list of indices to obtain the filenames, and use some python classes to read the subset of files using the filenames.
Let's say we have 15,000 images with the filenames stored in t...

1

votes

1

answer

299

Views

### Create a random bijective function which has same domain and range

Create a random bijective function which has same domain and range.
By random bijective function I mean a function which maps the elements from domain to range using a random algorithm (or at least a pseudo-random algo), and not something like x=y. The domain and range can be a very small set someti...

1

votes

1

answer

211

Views

### 1D Random Walk Expected Value

I have implemented a 1D random walk in C++ and Python; however, in both programs the expected value is not sqrt(N). I am wondering if there is a logic error in my code or some hidden factor that is making my outcome consistently low.
For those unfamiliar with random walk, the expected RMS value is s...

1

votes

1

answer

1.8k

Views

### tensorflow random forest regression

I would like to implement a simple random forest regression to predict a value. The inputs are some samples with several features, and the label is a value. However, I cannot find a simple example about the random forest regression problem. Thus, I saw the document of tensorflow and I found that:
An...

1

votes

0

answer

552

Views

### Text Categorization by uisng mlr package in R

I need to train a model which would perform multilabel multiclass categorization on text data.
Currently, i'm using mlr package in R. But unluckily I didn't proceed further because of the error I got it before training a model.
More specifically I'm stuck in this place:
classify.task = makeMultilabe...

1

votes

3

answer

70

Views

### Pseudorandom Number Generator with slight bias

I've thought about this for a while to no avail...
How would one go about creating a pseudorandom number generator with a slight (we're talking only apparent after millions, maybe billions, of iterations/tests) bias towards a single number. So, for example, if our generator is producing numbers from...

1

votes

1

answer

30

Views

### Randomize Return Results - Access

I need to match up an employee with a task in a small Microsoft Access DB I built. Essentially, I have a list of 45 potential tasks, and I have 25 employees. What I need is:
Each employee to have at LEAST one task
No employee to have more than TWO
Be able to randomize the results every time I run th...

1

votes

0

answer

13

Views

### how to use scanner.in array with strings and pick a random string?

The goal is to draw a random name from a hat using a switch command
String[] names = sc.next(); // how do I create an array of names with user
input? also, see case a.
case 'a':
System.out.println('\nPlease enter the names of the participants.');
final String[] names = {sc.next()};
/*how do I add...

1

votes

0

answer

99

Views

### An efficient function for generating random numbers in python based on PDF?

I am trying to make a random number generator that I could change the distribution based on its PDF, I know they are different random number generator in libraries available but I want to write a function that is customized, in the following, I tried to make this function for normal distribution. (a...

1

votes

1

answer

133

Views

### How to print a random number with random method in constructor? [JAVA]

I want to use a method called printOneRandom to print a random number, but I am only allowed to create one single instance of Random in the constructor. (I need to create a similar method which uses Random again later) My code:
import java.util.Random;
public class RandomNumberHandler
{
public Rand...

1

votes

1

answer

38

Views

### Shifting elements and printing each step

Im trying to shift elements in an array and print each step until they are back to their original positions. The array has to be filled with random numbers and must not be over the size of 15. I approached the task by creating a new array when the shifting occurs. If anyone has any better suggestion...

1

votes

1

answer

252

Views

### Img added by Javascript showing 0x0 pixels

I'm trying to add the same small image multiple times to a canvass. It shows in Inspect Elements correctly, except that the images have 0x0 pixels (natural is 200x45 or something).
Here's the code:
$(document).ready(function(){
var bgd1 = document.getElementById('background1'),
bgd2 = document.getEl...

1

votes

0

answer

163

Views

### Why is this Javascript/Ajax function using a random number?

I'm helping maintain a Javascript-based web site that was written by someone else. In their Javascript code, I came across this function, which downloads a file from the specified URL and calls a callback when the download is complete:
// ajax wrapper
function getServerData(command, command_label,...

1

votes

2

answer

145

Views

### Random function call from multiple threads in Qt/C++

I have a multi-thread QT application that sometimes need a random alphanumeric string from one of its threads (some threads start at application startup, others start or die during lifetime), and I would like to obtain that by calling a function defined in a common header, to avoid code replication....

1

votes

1

answer

75

Views

### Running random operations over vector, conditional

I am doing some modelling and wish to simulate randomness.
I have a total number of runs run_times which is 5 in this example.
A vector holding run_lengths will print 1's for which, so if run length is 3, it prints 1's 3 times.
The sample_data includes a sample of 1's and 0's. The application of p...

1

votes

1

answer

280

Views

### sklearn PCA random_state parameter function

I am using PCA to visualize clusters and noticed Sklearn added 'random_state' parameter to the PCA method (http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html), my question is what does the random_state parameter do there?
My understanding is that PCA should return the sa...

1

votes

0

answer

68

Views

### Getting a c++11 library on an older version of c++?

A remote machine that I don't own uses gcc 4.1.2 (2007 or so). I'd like to use the random library and its functions, which comes with the c++11 standard. Is there some way I can use the contents of ? Can I dump all of into a custom header?
I lack understanding of libraries and wonder if there's a...

1

votes

1

answer

75

Views

### FCMP function giving unexpected results in PROC SQL

I wanted to take Rick Wicklin's macro (https://blogs.sas.com/content/iml/2015/10/05/random-integers-sas.html) that generates random numbers and convert it into an FCMP function. The FCMP function works as expected when called using %sysfunc(randbetween(1,100)); or via a data step, but from proc sql...

1

votes

0

answer

22

Views

### Non Repeating Random Integer values within range of previous guessed values

I am creating random number game for my class where the computer guesses random values within the range set by the user. I am trying to get it to the point where if the user input Higher or Lower, the new values will not disobey the previous values. For example, if the range is between 2-50 and the...

1

votes

0

answer

270

Views

### Does SecureRandom use the same seed on each restart?

I'm currently trying to implement a password hash manager in Java. Looking for the best way to achieve this, I learned about salts.
This is the generateSalt function I've found :
public static byte[] generateSalt() throws NoSuchAlgorithmException {
SecureRandom random = SecureRandom.getInstance('SHA...

1

votes

1

answer

136

Views

### How to add packages from git to my Meteor project

I updated my Meteor project to 1.6.1 which no longer supports Meteor.uuid(). The package artwells:accounts-guest requires it and user baursn has submitted a merge of a pull request that updates the user of Meteor.uuid() to Random.id().
Artwells is yet to update the main package, so I'd like to use b...

1

votes

1

answer

176

Views

### Duplicate Tensorflow normal distribution objects

Given the following code:
import tensorflow as tf
normal_dist = tf.contrib.distributions.Normal(.5, 1.3)
foo = normal_dist.sample()
bar = normal_dist.sample()
baz = foo + bar
sess = tf.Session()
sess.run(tf.global_variables_initializer())
writer = tf.summary.FileWriter('./logs', graph=tf.get_default...

-1

votes

1

answer

791

Views

### How do I use Boost Random [closed]

I need to generate random number with Boost Random.
I tried to follow the general guide.
I extracted the files of the library. So if I want to use the classes and objectj of the library how I should do?
First I know including the library in the program. Then I have to compile the library and the p...

1

votes

1

answer

29

Views

### Creating n random lists

I'd like to create n random 10-number-lists using python, and put these lists in a single variable(ran).
Below is my code:
from random import shuffle
def gen_random_list (num):
ran = []
k = [n for n in range(1, 11)]
for i in range(num):
shuffle(k)
ran.append(k)
return ran
The expected output shou...

1

votes

0

answer

186

Views

### How to shuffle an iterator each iteration but be deterministic across program runs

Question
I'm confused by the Tensorflow documentation for randomness as it relates to the documentation for tf.Dataset.shuffle.
Specifically, I'm looking for a way to maintain deterministic behavior across different runs so I can obtain the same results each time I run the program, but still want to...

1

votes

0

answer

41

Views

### How to choose training data from a satellite imagery for supervised classification?

I am performing supervised classification of Sentinel 2 imagery using a Random Forest Classifier. I wish to select the training data from the image. Could anyone please tell me the method to efficiently perform this?

1

votes

0

answer

28

Views

### Uploading script does not update the progress bar

I am uploading a file to a Simple Auth protected web-page using ssl. It works, but the progress bar is not working, ie, it shows no progress and all of a sudden it's finished.
private fun hochladen(dn: String?): Int {
var upLoadServerUri = 'https://www.example.com/upload.php'
var conn: HttpURLConne...

1

votes

2

answer

39

Views

### HTML5 canvas random shapes

Okay, so I wrote the following code in an online code:
window.onload = function() {
var canvas = documentById('canvasArea');
var context = canvas.getContex('2d');
var numCircles = 500;
var maxRadius = 20;
var minRadius = 3;
var color = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'bl...

1

votes

1

answer

42

Views

### Tensorflow random distribution from tensor layer

I have a 4D array, and I am trying to select from this array all of the first three dimensions and then a random distribution of the fourth dimension
samples = np.unique( np.random.randint(subset_start, subset_end, size=50) )
layer_tensor = model.layer_tensors[model_layer][:, :, :, samples]
Whic...

1

votes

0

answer

232

Views

### Specify multiple nested random effects in lme with heteroskedastic variance across group

I want to fit a random effects model with two separate nested random effects. I can easily do this using the lmer package in R. Here's how:
model

1

votes

1

answer

30

Views

### Getting “No line found” when pulling values from an external file

Alright, so I need to grab some strings at random from a file not of a fixed size. So, to do this, I start by counting the lines in the file using a simple while loop. After that, I simply feed that value to a random object and store the ten values I need into the array:
int[] select = new int[10];...

1

votes

0

answer

179

Views

### Decision Tree Categorical and Continuous Variable

I'm new to data science and currently trying to learn and understand decision tree algorithm. I have a question about how the algorithm works when we have some continuous variables in a classification problem and categorical variables in regression problems.
Usually algo works on the basis of gini i...

1

votes

1

answer

52

Views

### Generate random item from list Excel 2003

I have a list of names in cells A1:A100, and I'm looking for a formula to enter into a cell that will select a random name from that range. I have spent much time searching to no avail, all solutions seem to be derived from the RANDBETWEEN function which is not part of Excel 2003, but only newer ver...

1

votes

0

answer

62

Views

### How do I generate a random process value given a set of moments or cumulants?

How would a create a data set from a known set of data moments or cumulants.
Its fairly easy to generate a random number with a known variance and mean.
I would like to get something that lets me submit an array of cumulants (or moments)
Example: (ci = cumulent, mi = momemts)
c1 = m1 or ‘mean’...

1

votes

1

answer

153

Views

### Custom representation of population with Python package deap

I am using Python package deap.
My problem is to get my population from dataset insted of generate it from genes.
For example:
I have [[1,2,0,0,...],[1,3,4,0,...],...] as data set
and I want to select random n elements from this data set to be my population.
Here is the code of making Population of...