Search Results

Search found 5192 results on 208 pages for 'random forests'.

Page 35/208 | < Previous Page | 31 32 33 34 35 36 37 38 39 40 41 42  | Next Page >

  • Architecture of chatroulette

    - by user317163
    Could somebody explain to me the architecture behind chatroulette? I was thinking about a similar project that would only implement Audio support (for starters). Is the best way to set this up a flash server? If so, how should I go about getting into flash, will I need flex 4? I have some beginner experience with c++, c# and java but I have never developed anything for the web. I was also wondering how the randomizer matches up the participants. How would you code something like this. Im obviously pretty clueless here and I'd greatly appreciate some advice regarding this problem -- I don't expect copy and paste solutions. It would just be nice to hear how you guys would tackle this problem. Thank you very much

    Read the article

  • How to randomize a sorted list?

    - by Faken
    Here's a strange question for you guys, I have a nice sorted list that I wish to randomize. How would i go about doing that? In my application, i have a function that returns a list of points that describe the outline of a discretized object. Due to the way the problem is solved, the function returns a nice ordered list. i have a second boundary described in math and want to determine if the two objects intersect each other. I simply itterate over the points and determine if any one point is inside the mathematical boundary. The method works well but i want to increase speed by randomizing the point data. Since it is likely that that my mathematical boundary will be overlapped by a series of points that are right beside each other, i think it would make sense to check a randomized list rather than iterating over a nice sorted one (as it only takes a single hit to declare an intersection). So, any ideas on how i would go about randomizing an ordered list?

    Read the article

  • JUnit Test method with randomized nature

    - by Peter
    Hey, I'm working on a small project for myself at the moment and I'm using it as an opportunity to get acquainted with unit testing and maintaining proper documentation. I have a Deck class with represents a deck of cards (it's very simple and, to be honest, I can be sure that it works without a unit test, but like I said I'm getting used to using unit tests) and it has a shuffle() method which changes the order of the cards in the deck. The implementation is very simple and will certainly work: public void shuffle() { Collections.shuffle(this.cards); } But, how could I implement a unit test for this method. My first thought was to check if the top card of the deck was different after calling shuffle() but there is of course the possibility that it would be the same. My second thought was to check if the entire order of cards has changed, but again they could possibly be in the same order. So, how could I write a test that ensures this method works in all cases? And, in general, how can you unit test methods for which the outcome depends on some randomness? Cheers, Pete

    Read the article

  • Thread-safty of boost RNG

    - by Maciej Piechotka
    I have a loop which should be nicely pararellized by insering one openmp pragma: boost::normal_distribution<double> ddist(0, pow(retention, i - 1)); boost::variate_generator<gen &, BOOST_TYPEOF(ddist)> dgen(rng, ddist); // Diamond const std::uint_fast32_t dno = 1 << i - 1; // #pragma omp parallel for for (std::uint_fast32_t x = 0; x < dno; x++) for (std::uint_fast32_t y = 0; y < dno; y++) { const std::uint_fast32_t diff = size/dno; const std::uint_fast32_t x1 = x*diff, x2 = (x + 1)*diff; const std::uint_fast32_t y1 = y*diff, y2 = (y + 1)*diff; double avg = (arr[x1][y1] + arr[x1][y2] + arr[x2][y1] + arr[x2][y2])/4; arr[(x1 + x2)/2][(y1 + y2)/2] = avg + dgen(); } (unless I make an error each execution does not depend on others at all. Sorry that not all of code is inserted). However my question is - are boost RNG thread-safe? They seems to refer to gcc code for gcc so even if gcc code is thread-safe it may not be the case for other platforms.

    Read the article

  • Looking for interesing formula

    - by Thinker
    I'm creating a game, where players can make an alloy. To make it less predictable, and more interesting, I thought that durability and hardness of an alloy can't be calculated by simple formula, because it will be extremely easy to find extrema, where alloy have best statistics. So the questions is, is there any formula for a function, where extrema can be found only by investigating all points? Input values will be in percents: 0.0%-100.0%. I think, it should look like this: half sound wave

    Read the article

  • How to get arc4Sin() output into label/NSString

    - by Moshe
    I'm trying to take the output of arc4sin and put it into a label. (EDIT: You can ignore this and just post sample code, if this is too irrelevant.) I've tried: // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; NSString *number = [[NSString alloc] stringWithFormat: @"%@", arc4random() % 9]; label.text = number; } I've created an IBOutlet for "label" and connected it. What's wrong here?

    Read the article

  • how to fadein LI elements randomly? (jquery)

    - by user366123
    Hi ive got a set of li with hover effect, what i want is when the page loads ALL the li fadein randomly. i don't want to shuffle them.....they should keep their ordering intact meaning 1,2,3,4,5.... just want to make them appear on the page randomly and stay there test page: http://humayunrehman.com/hovertest/

    Read the article

  • Visual Basic Express 2008 Help

    - by khalidfazeli
    I have been given a task to: Develop a program where a child will be presented with picture of a fruit (one of five possible fruit) on the screen at the click of a start button. The child will then try to recognise the fruit and write its name in a specified place on the screen. On the click of a check button the name of the fruit written by the child will be checked by your program and if correct will reward the child with a suitable message. If the name presented by the child is not correct, a suitable message should be presented on a red background with the correct name of the fruit included in the message. so far I have managed to create a form with 5 different fruit pictures and a text box below them. a button at the bottom of the form then checks the results and presents a message box to tell them if they have passed or failed. Private Sub btnResults_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnResults.Click If txtApple.Text = "APPLE" And txtOrange.Text = "ORANGES" And txtStrawberry.Text = "STRAWBERRIES" And txtGrapes.Text = "GRAPES" And txtBanana.Text = "BANANAS" Then MsgBox("Congratulations! you got it all right!", MsgBoxStyle.OkOnly) End Else MsgBox("Incorrect, please try again", MsgBoxStyle.OkOnly) End End If End Sub but I can't get it to randomise the picture of the fruit, so it only displays one fruit at a time and checks against it. Any help is appreciated. Thanks

    Read the article

  • weighted RNG speed problem in C++

    - by supert
    I have a (fast) bit of C++ code that samples cards from a 52 card deck: void sample_allcards(int table[5], int holes[], int players) { int temp[5 + 2 * players]; bool try_again; int c, n, i; for (i = 0; i < 5 + 2 * players; i++) { try_again = true; while (try_again == true) { try_again = false; c = fast_rand52(); // reject collisions for (n = 0; n < i + 1; n++) { try_again = (temp[n] == c) || try_again; } temp[i] = c; } } copy_cards(table, temp, 5); copy_cards(holes, temp + 5, 2 * players); } I am implementing code to sample the hole cards according to a known distribution (stored as a 2d table). My code for this looks like: void sample_allcards_weighted(double weights[][HOLE_CARDS], int table[5], int holes[], int players) { // weights are distribution over hole cards int temp[5 + 2 * players]; int n, i; // table cards for (i = 0; i < 5; i++) { bool try_again = true; while (try_again == true) { try_again = false; int c = fast_rand52(); // reject collisions for (n = 0; n < i + 1; n++) { try_again = (temp[n] == c) || try_again; } temp[i] = c; } } for (int player = 0; player < players; player++) { // hole cards according to distribution i = 5 + 2 * player; bool try_again = true; while (try_again == true) { try_again = false; // weighted-sample c1 and c2 at once double w[1326]; memcpy(w, weights[player], sizeof(w)); // h is a number < 1325 int h = weighted_randi(w, HOLE_CARDS); // i2h uses h and sets temp[i] to the 2 cards implied by h i2h(&temp[i], h); // reject collisions for (n = 0; n < i; n++) { try_again = (temp[n] == temp[i]) || (temp[n] == temp[i+1]) || try_again; } } } copy_cards(table, temp, 5); copy_cards(holes, temp + 5, 2 * players); } My problem? The weighted sampling algorithm is a factor of 10 slower. Speed is very important for my application. Is there a way to improve the speed of my algorithm to something more reasonable? Am I doing something wrong in my implementation? Thanks.

    Read the article

  • Looking for interesting formula

    - by Thinker
    I'm creating a game where players can make an alloy. To make it less predictable and more interesting, I thought that the durability and hardness of an alloy should not be calculated by a simple formula, because it will be extremely easy to find extrema, where alloy have best statistics. So the questions is, is there any formula for a function where extrema can be found only by investigating all points? Input values will be in percents: 0.0%-100.0%. I think it should look like this: half sound wave

    Read the article

  • Rand(); with exclusion to and already randomly generated number..?

    - by Stefan
    Hey, I have a function which calls a users associated users from a table. The function then uses the rand(); function to chose from the array 5 randomly selected userID's however!... In the case where a user doesnt have many associated users but above the min (if below the 5 it just returns the array as it is) then it gives bad results due to repeat rand numbers... How can overcome this or exclude a previously selected rand number from the next rand(); function call. Here is the section of code doing the work. Bare in mind this must be highly efficient as this script is used everywhere. $size = sizeof($users)-1; $nusers[0] = $users[rand(0,$size)]; $nusers[1] = $users[rand(0,$size)]; $nusers[2] = $users[rand(0,$size)]; $nusers[3] = $users[rand(0,$size)]; $nusers[4] = $users[rand(0,$size)]; return $nusers; Thanks in advance! Stefan

    Read the article

  • [Ruby] How can I randomly iterate through a large Range?

    - by void
    I would like to randomly iterate through a range. Each value will be visited only once and all values will eventually be visited. For example: (0..9).sort_by{rand}.map{|x| f(x)} where f(x) is some function that operates on each value. A Fisher-Yates shuffle could be used to increase efficiency, but this code is sufficient for many purposes. My problem is that sort_by will transform the range into an array, which is not cool because I am working with astronomically large numbers. Ruby will quickly consume a large amount of RAM trying to create a monstrous array. This is also why the following code will not work: tried = {} # store previous attempts bigint = 99**99 bigint.times { x = rand(bigint) redo if tried[x] tried[x] = true f(x) # some function } This code is very naive and quickly runs out of memory as tried obtains more entries. What sort of algorithm can accomplish what I am trying to do?

    Read the article

  • Where does that randomness come from ?

    - by Jules Olléon
    I'm working on a data mining research project and use code from a big svn. Apparently one of the methods I use from that svn uses randomness somewhere without asking for a seed, which makes 2 calls to my program return different results. That's annoying for what I want to do, so I'm trying to locate that "uncontrolled" randomness. Since the classes I use depend on many other, that's pretty painful to do by hand. Any idea how I could find where that randomness comes from ?

    Read the article

  • Code Golf: Ghost Leg

    - by Anax
    The challenge The shortest code by character count that will output the numeric solution, given a number and a valid string pattern, using the Ghost Leg method. Examples Input: 3, "| | | | | | | | |-| |=| | | | | |-| | |-| |=| | | |-| |-| | |-|" Output: 2 Input: 2, "| | |=| | |-| |-| | | |-| | |" Output: 1 Clarifications Do not bother with input. Consider the values as given somewhere else. Both input values are valid: the column number corresponds to an existing column and the pattern only contains the symbols |, -, = (and [space], [LF]). Also, two adjacent columns cannot both contain dashes (in the same line). The dimensions of the pattern are unknown (min 1x1). Clarifications #2 There are two invalid patterns: |-|-| and |=|=| which create ambiguity. The given input string will never contain those. The input variables are the same for all; a numeric value and a string representing the pattern. Entrants must produce a function. Test case Given pattern: "|-| |=|-|=|LF| |-| | |-|LF|=| |-| | |LF| | |-|=|-|" |-| |=|-|=| | |-| | |-| |=| |-| | | | | |-|=|-| Given value : Expected result 1 : 6 2 : 1 3 : 3 4 : 6 5 : 5 6 : 2

    Read the article

  • PHP Game weapon accuracy

    - by noko
    I'm trying to come up with a way for players to fire their weapons and only hit for a certain percentage. For example, one gun can only hit 70% of the time while another only hits 34% of the time. So far all I could come up with is weighted arrays. Attempt 1: private function weighted_random(&$weight) { $weights = array(($weight/100), (100-$weight)/100); $r = mt_rand(1,1000); $offset = 0; foreach($weights as $k => $w) { $offset += $w*1000; if($r <= $offset) return $k; } } Attempt 2: private function weapon_fired(&$weight) { $hit = array(); for($i = 0; $i < $weight; $i++) $hit[] = true; for($i = $weight; $i < 100; $i++) $hit[] = false; shuffle($hit); return $hit[mt_rand(0,100)]; } It doesn't seem that the players are hitting the correct percentages but I'm not really sure why. Any ideas or suggestions? Is anything glaringly wrong with these? Thanks

    Read the article

  • STL deque accessing by index is O(1)?

    - by jasonline
    I've read that accessing elements by position index can be done in constant time in a STL deque. As far as I know, elements in a deque may be stored in several non-contiguous locations, eliminating safe access through pointer arithmetic. For example: abc-defghi-jkl-mnop The elements of the deque above consists of a single character. The set of characters in one group indicate it is allocated in contiguous memory (e.g. abc is in a single block of memory, defhi is located in another block of memory, etc.). Can anyone explain how accessing by position index can be done in constant time, especially if the element to be accessed is in the second block? Or does a deque have a pointer to the group of blocks? Update: Or is there any other common implementation for a deque?

    Read the article

  • Looking for a fast hash-function.

    - by Julian
    Hello, I'm looking for a special hash-function. Let's say I have a large list of strings, if I order them by their hash-values they should be ordered quasi randomly. The most important point is: it must be super fast. I've tried md5 and sha1 and they're using to much cpu power. Clashes are not a problem. I'm using javascript, so it shouldn't be too complicated to implement.

    Read the article

  • Shuffling a list with a constraint

    - by 500
    Preparing a new psychophysic experiment, I have 48 original stimuli displayed 4 times (4 conditions). Resulting in 192 trials. Trying to randomize the order of presentation during the experiment, I need to maximize the distance between the 4 display of the same original stimuli. Please Consider : Table[{j, i}, {j, Range[48]}, {i, Range[4]}] Where j is the original stimuli number and i the condition Output Sample : {{1, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, ... {47, 1}, {47, 2}, {47, 3},{47, 4}, {48, 1}, {48, 2}, {48, 3}, {48, 4}} How could I shuffle the order of presentation of those 192 items, maximizing the distance between identical item with regard to j the original stimuli number ?

    Read the article

  • Strange phantom header margin bug html/css

    - by MickyJimbo
    So I'm creating this website and there is a strange untraceable bug that causes the header to move down 10 or so pixels. On a refresh the header could be correct or it could be broken. I've been testing it on Adobe Browserlab and the results are different every time.There is no discernible pattern making it incredible hard to track down. http://www.freeimagehosting.net/uploads/c866bf594d.jpg Has anyone ever had this problem and been able to fix it?

    Read the article

  • PHP, MySQL - would results-array shuffle be quicker than "select... order by rand()"?

    - by sombe
    I've been reading a lot about the disadvantages of using "order by rand" so I don't need update on that. I was thinking, since I only need a limited amount of rows retrieved from the db to be randomized, maybe I should do: $r = $db->query("select * from table limit 500"); for($i;$i<500;$i++) $arr[$i]=mysqli_fetch_assoc($r); shuffle($arr); (i know this only randomizes the 500 first rows, be it). would that be faster than $r = $db->("select * from table order by rand() limit 500"); let me just mention, say the db tables were packed with more than...10,000 rows. why don't you do it yourself?!? - well, i have, but i'm looking for your experienced opinion. thanks!

    Read the article

< Previous Page | 31 32 33 34 35 36 37 38 39 40 41 42  | Next Page >