random

Java Random Slowdowns on Mac OS cont'd

I asked this question a few weeks ago, but I'm still having the problem and I have some new hints. The original question is here: http://stackoverflow.com/questions/1651887/java-random-slowdowns-on-mac-os Basically, I have a java application that splits a job into independent pieces and runs them in separate threads. The threads have...

how can I create a password?

I want to give maybe a million password to some users that should be like: it must have at least 6 characters it must have digits and also letters Should I use Random here? How? ...

Comprehensive information about hash salts

There are a lot of questions about salts and best practices, however most of them simply answer very specific questions about them. I have several questions which feed into one another. Assuming a database is compromised a per user salt prevents the use of generic rainbow tables to crack passwords. A separate rainbow table would have ...

replace or remove one null (python)

Hi Everyones, I would like to remove one null byte in a string, and sometime replace it with another char. Like that : string = "41 00 36 00 36 00 00 00 57 00 46 00 42 00 41 00 61 00 62 00 73 00 20 00 36 00" i was thinking about using random and replace, but replace always start by the first one: replace("00","B",1) So it's not ran...

use random functions (python)

Hi, I wonder if we can do that in python, let's suppose we have 3 differents functions to processing datas like this: def main(): def process(data): ..... def process1(data): ..... def process2(data): ..... def run(): test = choice([process,process1,process2]) test(data) run() main() Can we choice...

Fastest way to pick a random element from a list that fulfills certain condition

I need to pick a random element from a list, that fulfills certain condition. The approach I've been using works, but I'm sure is not every efficient. What would be the most efficient way to do it? The following code is inside a while (true) loop, so obviously is not very efficient to shuffle the list on every iteration. Foo randomPick...

Weighted random numbers

I'm trying to implement a weighted random numbers. I'm currently just banging my head against the wall and cannot figure this out. In my project (Hold'em hand-ranges, subjective all-in equity analysis), I'm using Boost's random -functions. So, let's say I want to pick a random number between 1 and 3 (so either 1, 2 or 3). Boost's mersen...

Random prime number

How do I quickly generate a random prime number, that is for sure 1024 bit long? ...

Is there a way to distinguish a GUID from just a random number?

Being able to distinguish a GUID from random data can be useful when debugging obscure code defects. On Windows each GUID generated is of version 4 therefore it has '4' as the first half-byte of the third part. So if the 16-byte sequence violtates that rule it is not a version 4 GUID. For example, 567E1ECB-EA1C-42D3-A3ED-87A5D824D167 ...

Get Random Rows Using JPQL

Is it possible to use JPQL for getting random rows? For example in SQL Server I would use: select * from myTable where columnName = 4 order by newid() Thanks, Rod ...

Why do I get the same result with rand() every time I compile and run?

Whenever I run this code, I get a same result. Program #include<stdlib.h> int main(int agrc, const char *argv[]) { int i = rand(); printf("%d\n",i); for(i=0;i<10;i++) { printf("%d\n",rand()); } } Result: 41 18467 6334 26500 19169 15724 11478 29358 26962 24464 5705 I ran this on mingw. Actually I am learning Objective-C Ple...

Linq2sql: efficient way to get random elements with weight?

Byt lets say I have an integer weight where i.e. elements with weight 10 has 10 times higher probability to be selected than element with weight 1. var ws = db.WorkTypes .Where(e => e.HumanId != null && e.SeoPriority != 0) .OrderBy(e => /*????*/ * e.SeoPriority) .Select(e => new { DescriptionText = e.DescriptionText, HumanId = e....

How to fix value produced by Random?

Hi all, I got an issue which is, in my code,anyone can help will be great. this is the example code. from random import * from numpy import * r=array([uniform(-R,R),uniform(-R,R),uniform(-R,R)]) def Ft(r): for i in range(3): do something here, call r return something however I found that in python shell, every tim...

AdvancedDataGrid dataFields refresh

Hi All I have a problem with an AdvancedDataGrid; i want the fields Actual and Estimate to change with the timer function but it doesn't work. It works only by refreshing all the adg with the collapse of the tree structure. I want that if the tree is "exploded" only actual and estimate fields refresh. Sorry for my uncorrect english. Here...

Random Linq Query

Hi guys, how I can get a random row from a selection in my linq query? I tried: Bot bot = (from a in dc.Bot select a).OrderBy(x => Guid.NewGuid()).First(); But doesn't work, I ever get the same. ...

java.util.Random peculiarity

So here is one of the simplest things one might do: Random rng = new Random(); int a = rng.nextInt(10); int b = rng.nextInt(10); So far so good. But we want to avoid having equal a and b, so naturally we do: Random rng = new Random(); int a = rng.nextInt(10); int b = rng.nextInt(10); while (a == b){ b = rng.nextInt(10); } However...

How to randomly sort (scramble) an array in Ruby?

I'd like to have my array items scrambled. Something like this: [1,2,3,4].scramble => [2,1,3,4] [1,2,3,4].scramble => [3,1,2,4] [1,2,3,4].scramble => [4,2,3,1] and so on, randomly ...

Creating a repeatable, random looking distribution of objects in Flash

I'm trying to scatter movie clips around the stage using Actionscript 3 in a way that looks as though they were randomly placed there, like photographs spread out on a table top. I tried using a spiral type arrangement, but found it too uniform, and also a circular distribution, but found that too random. The other factor is that i'd l...

MySQL: Alternatives to ORDER BY RAND()

I've read about a few alternatives to MySQL's ORDER BY RAND() function, but most of the alternatives apply only to where on a single random result is needed. Does anyone have any idea how to optimize a query that returns multiple random results, such as this: SELECT u.id, p.photo FROM users u, profiles p WHER...

Statistical mathematics issues

Hello, I'm developing a Texas Hold 'em hand-range equity evaluator, which evaluates hand-distributions with Monte Carlo -simulation. I've faced two annoying problems which behaviors I cannot give any reason. Problem #1: In a nut shell, the evaluator works by first picking up hands from player's hand-distributions. Say, that we have th...