seed

What is a cross platform way to select a random seed in Java?

After reading this answer: http://stackoverflow.com/questions/136474/best-way-to-pick-a-random-subset-from-a-collection#136513 It got me wondering, how does one pick a random seed in Java? And don't say use System.currentTimeMillis() or System.nanoTime(). Read the article to see why not. That's a hard question, but let me make it har...

Random distribution of data

How do I distribute a small amount of data in a random order in a much larger volume of data? For example, I have several thousand lines of 'real' data, and I want to insert a dozen or two lines of control data in a random order throughout the 'real' data. Now I am not trying to ask how to use random number generators, I am asking a st...

How to create my own JavaScript Random Number generator that I can also set the seed

The JavaScript Math.random() function returns a random value between 0 and 1 (automatically seeded based on the current time (similar to Java I believe)). However I'd like to make a more robust function that accepts a min, a max, and (optionally) a seed. I found this code kicking around and it appears to work fine for getting a random ...

What is a good hashing algorithm for seeding a prng with a string?

I am looking for a hashing algorithm that produces a 31/32 bit signed/unsigned integer as a digest for a utf8 string with the purpose of using the output for seeding a prng, such as a Park-Miller-Carta LCG or a Mersenne-Twister. I have looked into FNV1 and FNV1a, but they provide very close values for similar strings differing in their ...

What is the best way to seed a database in Rails?

I have a rake task that populates some initial data in my rails app. For example, countries, states, mobile carriers, etc. The way I have it set up now, is I have a bunch of create statements in files in /db/fixtures and a rake task that processes them. For example, one model I have is themes. I have a theme.rb file in /db/fixtures t...

Python's random: What happens if I don't use seed(someValue)?

a)In this case does the random number generator uses the system's clock (making the seed change) on each run? b)Is the seed used to generate the pseudo-random values of expovariate(lambda)? ...

How can I get rid of the warning with rand()? (C++)

Whenever I use the rand function in C++: #include<iostream> #include<time.h> #include<stdlib.h> using namespace std; int main(){ srand(time(0)); int n=(rand()%6)+1; cout<<"The dice roll is "<<n<<"."<<endl; } I get a warning about conversion from time_t to int at line 5: srand(time(0)); Is there any way to get rid of this warning? ...

Seed Mechanism does not work fine for BlackBerry

Hi I have created AES key in java using seed mechanism and the same thing using BlackBerry. My input string for Seed is same in both of these case. But I am getting different AES. But the created AES key should be same. Is there any online help for creating AES key using seed mechanism for BlackBerry Thanks Deepak ...

Issues with seeding a pseudo-random number generator more than once?

I've seen quite a few recommendations for not seeding pseudo-random number generators more than once per execution, but never accompanied by a thorough explanation. Of course, it is easy to see why the following (C/C++) example is not a good idea: int get_rand() { srand(time(NULL)); return rand(); } since calling get_rand several ...

Ruby on Rails - is seeding data with fixtures dangerous?

I have fixtures with initial data that needs to reside in my database (countries, regions, carriers, etc.). I have a task rake db:seed that will seed a database. namespace :db do desc "Load seed fixtures (from db/fixtures) into the current environment's database." task :seed => :environment do require 'active_record/fixtures' ...

Getting a name error when seeding a database in ruby on rails. How do I include app context?

I have a seed script called load.rb in the db directory of an application. I just got this app from a client so not sure how to run this script. I get a name error on all of the Model.create(...) statements. I guess this is because the Rails environment is not loaded. There is no indication that this load script was run via a rake ta...

Seed data for sentiment analysis

I'm playing around with sentiment analysis, and I'm looking for some seed data. Is there a free dictionary around? It can be really simple: 3 sets of texts/sentences, for "positive", "negative", "neutral". It doesn't have to be huge. Eventually I'll probably generate my own seed data for my specific use case, but it would be great to...

How to load db:seed data into test database automatically?

I'm attempting to use the new standard way of loading seed data in Rails 2.3.4+, the db:seed rake task. I'm loading constant data, which is required for my application to really function correctly. What's the best way to get the db:seed task to run before the tests, so the data is pre-populated? ...

Using a method in seeds.rb in Ruby On Rails

I am trying to add a method to my seeds.rb so that I don't have to write a bunch of verbose code. However, depending on the placement of the create_deliverable method I get one of two error messages when running db:setup. When method is before call rake aborted! private method 'create_deliverable' called for # When method is aft...

Where did foodscanner get its initial barcode database?

http://dailyburn.com/foodscanner Any ideas? ...

boost::random generate the same number every time

main .cpp #include "stdafx.h" #include "random_generator.h" int main ( int argc, char *argv[] ) { cout.setf(ios::fixed); base_generator_type base_generator; int max = pow(10, 2); distribution_type dist(1, max); boost::variate_generator<base_generator_type&, distribution_ty...

Prevent Rails test from deleting seed data

I am using seeds.rb to populate some State model reference data: State.create :name => 'Alabama', :abbreviation => 'AL' State.create :name => 'Alaska', :abbreviation => 'AK' # ... Although I am not using state fixtures (since it's seed data to begin with, I think it wouldn't be DRY to have to duplicate this purely for tests), the Rail...

Better random algorithm?

I'm making a game in c++ and it involves filling tiles with random booleans (either yes or no) whether it is yes or no is decided by rand() % 1. It doesnt feel very random. I'm using srand with ctime at startup, but it seems like the same patterns are coming up. Are there any algorithms that will create very random numbers? Or any sugges...

Populating globalized (Globalize2) DB using db:seed

I,m using Globalize2. I'd like to populate DB with db:seed for different locales: en, de and ru. Is there a better solution then: categories = [{ :en => 'Health & Beauty', :ru => 'Красота и здоровье', :de => 'Beauty & Gesundheit'}, { :en => 'Baby', :ru => 'Детские товары', :de => 'Baby' }] categories.each_index do |i| I...

Changing Identity Seed in SQL Server (Permanently!)

Is there any way of changing the identity seed for an identity column permanently? Using DBCC CHECKIDENT just seems to set the last_value. If the table is truncated all values are reset. dbcc checkident ('__Test_SeedIdent', reseed, 1000) select name, seed_value, increment_value, last_value from sys.identity_columns where [object_id] = ...