# Populating a list is Scala with random double

Hi,

I am writing Big Data Analytics program and there is need of populating random double values. Is there any easy for this?

I want code for Populating a list is Scala with random double.

Thanks

November 12, 2017 at 7:08 PM

Hi,

You can use following code to generate random double:

``` val f = List.fill(200)(math.random)
```

Above code generates 200 random double and fills into list. You can also write code as shown below:

```Array.fill(200)(math.random)
```

Here sample output of the program:

```scala> val f = List.fill(200)(math.random)
f: List[Double] = List(0.8177392605405407, 0.6564263397990546,
0.4524370695806057, 0.46530598807444123, 0.4448807267968605,
0.5995599114887837, 0.15604115934929874, 0.41011415871847934,
0.41615741907429193, 0.9305082942231618, 0.11074738420430352,
0.7024134139103135, 0.46581611081575336, 0.1824714768449518,
0.5224807778207685, 0.6624941180263288, 0.18373595103468832,
0.16260563831694952, 0.12598396140802126, 0.6421874802971818,
0.12044622248102277, 0.761989627776956, 0.1829725678674904,
0.04614957832947053, 0.9465237945692694, 0.6868608690256842,
0.6632862161215008, 0.036942238094971214, 0.930
6823527702981, 0.5045838092652264, 0.1882895380148497,
0.6362215986746129, 0.04481235271097528, 0.5120718288206062,
0.8128475910954386, 0.6267280169944165, 0.20442428068223617,
0.4548914339909159, ...
scala>
```

Thanks

Populating a list is Scala with random double
Populating a list is Scala with random double  Hi, I am writing Big Data Analytics program and there is need of populating random double values. Is there any easy for this? I want code for Populating a list is Scala with random
How to generate a list of random numbers?
How to generate a list of random numbers?  Hi, How to generate a list of random numbers? I want code in scala programming language. Thanks  ... of Scala programming and it generates random integer. Following program
Generate Random Integer Between Two Values in Scala
Generate Random Integer Between Two Values in Scala  Hi, I am working on the SCALA project and want to generate random integer between two numbers. How to Generate Random Integer Between Two Values in Scala? Thanks
Generate random number between two numbers in Scala
Generate random number between two numbers in Scala  Hi, How to Generate random number between two numbers in Scala? Thanks   Hi, Following code can be used for generating random number in scala: val rand = new
Version of taglibs>random dependency
List of Version of taglibs>random dependency
populating the combo box - Struts
populating the combo box  Hi I am having problem populating...) { ArrayList list = new ArrayList(); try { connectToDb(); // String sec = null... { closeConnection(); } return list; } public ArrayList getCompanyBySector
Version of taglibs>random-doc dependency
List of Version of taglibs>random-doc dependency
Version of taglibs>random-examples dependency
List of Version of taglibs>random-examples dependency
Populating child dropdownlists in JSP/Servlet
Populating child dropdownlists in JSP/Servlet  Populating child dropdownlists in JSP/Servlet
Version of com.danielasfregola>random-data-generator_2.10 dependency
List of Version of com.danielasfregola>random-data-generator_2.10 dependency
Version of com.danielasfregola>random-data-generator_2.11 dependency
List of Version of com.danielasfregola>random-data-generator_2.11 dependency
Version of com.danielasfregola>random-data-generator_2.12 dependency
List of Version of com.danielasfregola>random-data-generator_2.12 dependency
populating a screen on the same page
populating a screen on the same page  i'm making a time table in jsp. i have put button on each slot.if a person click on that slot it'll redirect to a new page which will help them to choose the subject and faculty through drop
Random classes
Random classes  Hello... What is Random class? What's the purpose
Random classes
Random classes  Hello... What is Random class? What's the purpose
Random classes
Random classes  Hello... What is Random class? What's the purpose
Pick at Random
Pick at Random  I am working on a page to gather all the names of the people, put them into a list, then shuffle the names and spit them back out... the entry from the array before selecting another name at random
random number
random number  Sir could u please send me the code registration form of roseindia.net with image varification
random number
random number   Please How do I generate a program that gives me random integer from 115 to 250? Using java.util.random. Thank you very much!  ...[] args){ int min = 115; int max = 250; Random random = new Random
populating text box using jsp code
populating text box using jsp code  Sir, How to populate related values in a text box after selecting value from drop down list using JSP and mysql..., `writer` varchar(255) default NULL, `Price` double default NULL, PRIMARY KEY (`id
Version of com.hankcs>aho-corasick-double-array-trie dependency
List of Version of com.hankcs>aho-corasick-double-array-trie dependency
random numbers
random numbers  hi.. i am creating a website and on feedback form to authenticate user i want to generate a random number on label.if user types that number correctly in textbox then he is allowed to submit feedback otherwise
NSString to double
NSString to double  Hi, I want to convert NSString value into double. Please give me good code example for this conversion. Thanks   Hi... scannerWithString:@"1.309"]; double dblLat; [strLat scanDouble:&
NSString to double
NSString to double  Hi, I want to convert NSString value into double. Please give me good code example for this conversion. Thanks
Random in jsp
Random in jsp          Random numbers are the numbers that are determined entirely by chance. User does not have any control over the working of random numbers
string to double
string to double   So I have an assignment where we have to convert..., parseDouble() method takes a String as input and converts it into a double when possible and returns it. If the string cannot be converted into a positive double
Generate shuffling in the specified list
and print the list according to the generated random number...", "Komal"}; // create list for the specified array of employee. List list1 = Arrays.asList(employee); // create object of Random class
random numbers
random numbers  Hi I need some help with the code for the this program. This program should randomly choose a number between 1 and 1000, and then challenge the user to guess what it is, giving hints ('too high!' or 'too low
Random Access File.
Random Access File.  Explain Random Access File
random numbers - Java Beginners
random numbers  Hello i need this code to be modified for me to display the random numbers, but not twice or more. I mean i need a number... RandomNumberExample { static Random generator = new Random(); public static int get (int[] array
How to convert String double quotos to String double double quotes(
How to convert String double quotos to String double double quotes(  Hi How to convert String double quotos to String double double quotes("----->"") By replace? Problem is: String column is "Age is 60" now . whenver