Search Results

Search found 10679 results on 428 pages for 'random numbers'.

Page 6/428 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Random Number on SQL without using NewID()

    - by Angel Escobedo
    Hello I want to generate a Unique Random number with out using the follow statement : Convert(int, (CHECKSUM(NEWID()))*100000) AS [ITEM] Cause when I use joins clauses on "from" it generates double registers by using NEWID() Im using SQL Server 2000 *PD : When I use Rand() it probably repeat on probability 1 of 100000000 but this is so criticall so it have to be 0% of probability to repeat a random value generated My Query with NewID() and result on SELECT statement is duplicated (x2) My QUery without NewID() and using Rand() on SELECT statement is single (x1) but the probability of repeat the random value generated is uncertainly but exists! Thanks!

    Read the article

  • Generating random numbers in C

    - by moonstruckhorrors
    While searching for Tutorials on generating random numbers in C I found This Topic When I try to use the rand() function with parameters, I always get the random number generated 0. When I try to use the rand() function with parameters, I always get the value 41. And whenever I try to use arc4random() and random() functions, I get a LNK2019 error. Here's what I'm doing: #include <stdlib.h> int main() { int x; x = rand(6); printf("%d", x); } This code always generate 41. Where am I going wrong?? P.S. : I'm running Windows XP SP3 and using VS2010 Command Prompt as compiler. P.P.S. : Took me 15 minutes to learn how to format properly.

    Read the article

  • Read random lines from huge CSV file in Python

    - by jbssm
    I have this quite big CSV file (15 Gb) and I need to read about 1 million random lines from it. As far as I can see - and implement - the CSV utility in Python only allows to iterate sequentially in the file. It's very memory consuming to read the all file into memory to use some random choosing and it's very time consuming to go trough all the file and discard some values and choose others, so, is there anyway to choose some random line from the CSV file and read only that line? I tried without success: import csv with open('linear_e_LAN2A_F_0_435keV.csv') as file: reader = csv.reader(file) print reader[someRandomInteger] A sample of the CSV file: 331.093,329.735 251.188,249.994 374.468,373.782 295.643,295.159 83.9058,0 380.709,116.221 352.238,351.891 183.809,182.615 257.277,201.302 61.4598,40.7106

    Read the article

  • Good Form for Random Number Generator?

    - by JackCJR
    I wanted to get a few opinions on doing a random number generator. I read through a couple different ways to do it and this is the way that I created after doing a little reading. Is it acceptable form? Any foreseeable issues? function master(){ function generate(){ var pickFrom= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var j = pickFrom.length; var i = Math.floor(Math.random()*j+1); //Generates a random number var code = pickFrom.charAt(i) //Picks a number based on what number was picked. document.write(code) } x = 1; while(x){ generate(); x--; } } master();

    Read the article

  • Diehard test only integers?

    - by emmy
    i want to test some "random" numbers in (0 1). i will test them with the diehard tests battery, but i dont know if it tests numbers in (0 1). so diehard test any kind of numbers, or it just test intergers?

    Read the article

  • Best way to store list of numbers and to retrieve them

    - by bingoNumbers
    Hi. What is the best way to store a list of random numbers (like lotto/bingo numbers) and retrieve them? I'd like to store on a Database a number of rows, where each row contains 5-10 numbers ranging from 0 to 90. I will store a big number of those rows. What I'd like to be able is to retrieve the rows that have at least X number in common to a newly generated row. Example: [3,4,33,67,85,99] [55,56,77,89,98,99] [3,4,23,47,85,91] Those are on the DB I will generate this: [1,2,11,45,47,88] and now I want to get the rows that have at least 1 number in common with this one. The easiest (and dumbest?) way is to make 6 select and check for similar results. I thought to store numbers with a large binary string like 000000000000000000000100000000010010110000000000000000000000000 with 99 numbers where each number represent a number from 1 to 99, so if I have 1 at the 44th position, it means that I have 44 on that row. This method is probably shifting the difficult tasks to the Db but it's again not very smart. Any suggestion?

    Read the article

  • how to display numbers without garbage numbers?

    - by Medeti Naveen Kumar
    Hi friends, whenever i press the numbers in text filed upto 9 numbers my textfield has taken right values but i press 10 th number.i have found duplicate number. in my header file i declare a pressnumber is "long long int" -(IBAction)press:(id)sender{ pressNumber = pressNumber*10 + (int)[sender tag]; phonenumber.text = [NSString stringWithFormat:@"%d",currentNumber]; } i want to enter a phone number in my textfiled but it is not taken 10 right numbers. Thanking you,

    Read the article

  • JSF - Random Number using Beans (JAVA)

    - by Alex Encore Tr
    I am trying to create a jsf application which, upon page refresh increments the hit counter and generates two random numbers. What should be displayed on the window may look something like this: On your On your roll x you have thrown x and x For this program I decided to create two Beans, one to hold the page refresh counter and one to generate a random number. Those look like this for the moment: CounterBean.java package diceroll; public class CounterBean { int count=0; public CounterBean() { } public void setCount(int count) { this.count=count; } public int getCount() { count++; return count; } } RandomNumberBean.java package diceroll; import java.util.Random; public class RandomNumberBean { int rand=0; Random r = new Random(); public RandomNumberBean() { rand = r.nextInt(6); } public void setNextInt(int rand) { this.rand=rand; } public int getNextInt() { return rand; } } I have then created an index.jsp to display the above message. <html> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <f:view> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Roll the Dice</title> </head> <body> <h:form> <p> On your roll # <h:outputText value="#{CounterBean.count} " /> you have thrown <h:outputText value="#{RandomNumberBean.rand}" />and <h:outputText value="#{RandomNumberBean.rand} " /> </p> </h:form> </body> </f:view> </html> However, when I run the application, I get the following message: org.apache.jasper.el.JspPropertyNotFoundException: /index.jsp(14,20) '#{RandomNumberBean.rand}' Property 'rand' not found on type diceroll.RandomNumberBean Caused by: org.apache.jasper.el.JspPropertyNotFoundException - /index.jsp(14,20) '#{RandomNumberBean.rand}' Property 'rand' not found on type diceroll.RandomNumberBean I suppose there's a mistake with my faces-config.xml file, so I will post this here as well, see if somebody can provide some help: faces-config.xml <?xml version="1.0" encoding="UTF-8"?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0"> <managed-bean> <managed-bean-name>CounterBean</managed-bean-name> <managed-bean-class>diceroll.CounterBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> <managed-bean> <managed-bean-name>RandomNumberBean</managed-bean-name> <managed-bean-class>diceroll.RandomNumberBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> </faces-config>

    Read the article

  • C# Monte Carlo Incremental Risk Calculation optimisation, random numbers, parallel execution

    - by m3ntat
    My current task is to optimise a Monte Carlo Simulation that calculates Capital Adequacy figures by region for a set of Obligors. It is running about 10 x too slow for where it will need to be in production and number or daily runs required. Additionally the granularity of the result figures will need to be improved down to desk possibly book level at some stage, the code I've been given is basically a prototype which is used by business units in a semi production capacity. The application is currently single threaded so I'll need to make it multi-threaded, may look at System.Threading.ThreadPool or the Microsoft Parallel Extensions library but I'm constrained to .NET 2 on the server at this bank so I may have to consider this guy's port, http://www.codeproject.com/KB/cs/aforge_parallel.aspx. I am trying my best to get them to upgrade to .NET 3.5 SP1 but it's a major exercise in an organisation of this size and might not be possible in my contract time frames. I've profiled the application using the trial of dotTrace (http://www.jetbrains.com/profiler). What other good profilers exist? Free ones? A lot of the execution time is spent generating uniform random numbers and then translating this to a normally distributed random number. They are using a C# Mersenne twister implementation. I am not sure where they got it or if it's the best way to go about this (or best implementation) to generate the uniform random numbers. Then this is translated to a normally distributed version for use in the calculation (I haven't delved into the translation code yet). Also what is the experience using the following? http://quantlib.org http://www.qlnet.org (C# port of quantlib) or http://www.boost.org Any alternatives you know of? I'm a C# developer so would prefer C#, but a wrapper to C++ shouldn't be a problem, should it? Maybe even faster leveraging the C++ implementations. I am thinking some of these libraries will have the fastest method to directly generate normally distributed random numbers, without the translation step. Also they may have some other functions that will be helpful in the subsequent calculations. Also the computer this is on is a quad core Opteron 275, 8 GB memory but Windows Server 2003 Enterprise 32 bit. Should I advise them to upgrade to a 64 bit OS? Any links to articles supporting this decision would really be appreciated. Anyway, any advice and help you may have is really appreciated.

    Read the article

  • Code Golf: MSM Random Number Generator

    - by Vivin Paliath
    The challenge The shortest code by character count that will generate (pseudo)random numbers using the Middle-Square Method. The Middle-Square Method of (pseudo)random number generation was first suggested by John Von Neumann in 1946 and is defined as follows: Rn+1 = mid((Rn)2, m) For example: 34562 = 11943936 mid(11943936) = 9439 94392 = 89094721 mid(89094721) = 0947 9472 = 896809 mid(896809) = 9680 96802 = 93702400 mid(93702400) = 7024 Test cases: A seed of 8653 should give the following numbers (first 10): 8744, 4575, 9306, 6016, 1922, 6940, 1636, 6764, 7516, 4902

    Read the article

  • random() in python

    - by Arkapravo
    In python the function random() generates a random float uniformly in the semi-open range [0.0, 1.0). In principle can it ever generate 0.0 (i.e. zero) and 1.0 (i.e. unity)? What is the scenario in practicality?

    Read the article

  • Random position without overlapping

    - by Hwang
    How to stop MCs from overlapping each other? private function loadWishes():void { for (i; i } } private function checkOverlap(wishB:MovieClip) { wishB.x=Math.random()*stage.stageWidth; wishB.y=Math.random()*stage.stageHeight; for (var i:uint=0; i This doesn't seems to be working cause the amount of it checking whether MC is overlapping is about the amount of MC on stage. how to make it keep checking till everything's fine?

    Read the article

  • How would I create a random number?

    - by Elliot Bonneville
    How would I create a random number using C++? I've heard that one should use the time as a seed, but I'm not sure how to do that with the correct syntax. How would I do this? One more thing - how would I limit the random number to a particular range? I'm simulating a dice roll and getting numbers in the millions...

    Read the article

  • how to generate a random String? in java

    - by chandra wibowo
    hi everyone, i have an object called Student, and it has studentName, studentId, studentAddress, etc. for the studentId, i have to generate random string consist of seven numeric charaters, eg. studentId = getRandomId(); studentId = "1234567" <-- from the random generator. and i have to make sure that there is no duplicate id. thanks in advance

    Read the article

  • True random number generator

    - by goldenmean
    Sorry for this not being a "real" question, but Sometime back i remember seeing a post here about randomizing a randomizer randomly to generate truly random numbers, not just pseudo random. I dont see it if i search for it. Does anybody know about that article?

    Read the article

  • Interesting task using random numbers only

    - by psihodelia
    Given any number of the random real numbers from the interval [0,1] is there exist any method to construct a floating point number with zero decimal part? Your algorithm can use only random() function calls and no variables or constants. No constants and variables are allowed, no type casting is allowed. You can use for/while, if/else or any other programming language operands.

    Read the article

  • Generate a random filename in unix shell

    - by R S
    Hello, I would like to generate a random filename in unix shell (say tcshell). The filename should consist of random 32 hex letters, e.g.: c7fdfc8f409c548a10a0a89a791417c5 (to which I will add whatever is neccesary). The point is being able to do it only in shell without resorting to a program.

    Read the article

  • Implementation of java.lang.Random in PHP and C

    - by justinhj
    I'm looking for a random number generator that I can run in PHP, C and Java that will always return the same sequence of numbers for a given seed. Here's the Java implementation I would use: java.util.random source Whilst this would be fairly straightforward to port to C and PHP, there is potentially a lot of work to get all the edge cases correct and handle differences in number representation. I'd be extremely happy to just copy and paste a fully tested version should it exist.

    Read the article

  • Weighted random numbers in MATLAB

    - by yuk
    How to randomly pick up N numbers from a vector a with weight assigned to each number? Let's say: a = 1:3; % possible numbers weight = [0.3 0.1 0.2]; % corresponding weights In this case probability to pick up 1 should be 3 times higher than to pick up 2. Sum of all weights can be anything.

    Read the article

  • Generate 3 random number that sum to 1 in R

    - by user1034797
    I am hoping to create 3 (non-negative) quasi-random numbers that sum to one, and repeat over and over. Basically I am trying to partition something into three random parts over many trials. While I am aware of a= runif(3,0,1) I was thinking that I could use 1-a as the max in the next run if, but it seems messy. But these of course don't sum to one. Any thoughts, oh wise stackoverflow-ers?

    Read the article

  • Using boost::random as the RNG for std::random_shuffle

    - by Greg Rogers
    I have a program that uses the mt19937 random number generator from boost::random. I need to do a random_shuffle and want the random numbers generated for this to be from this shared state so that they can be deterministic with respect to the mersenne twister's previously generated numbers. I tried something like this: void foo(std::vector<unsigned> &vec, boost::mt19937 &state) { struct bar { boost::mt19937 &_state; unsigned operator()(unsigned i) { boost::uniform_int<> rng(0, i - 1); return rng(_state); } bar(boost::mt19937 &state) : _state(state) {} } rand(state); std::random_shuffle(vec.begin(), vec.end(), rand); } But i get a template error calling random_shuffle with rand. However this works: unsigned bar(unsigned i) { boost::mt19937 no_state; boost::uniform_int<> rng(0, i - 1); return rng(no_state); } void foo(std::vector<unsigned> &vec, boost::mt19937 &state) { std::random_shuffle(vec.begin(), vec.end(), bar); } Probably because it is an actual function call. But obviously this doesn't keep the state from the original mersenne twister. What gives? Is there any way to do what I'm trying to do without global variables?

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >