I often have to generate random vectors so I created this simple online utility that does it for me. It lets you generate random row or column vectors with any number of elements. It works in the browser and is powered by alien technology from the future.

Random Vector Generator Options

Vector Length and Direction
Generate coordinates horizontally.
Generate coordinates vertically.
Interval and Type
Delimeters

Random Vector Generator Examples (click to try!)

Random Row Vector
In this example, we generate a random horizontal vector with 5 coordinates. The elements are integers and belong to the range from 1 to 100. Each vector element is double-quoted, there's a comma between all elements and the vector is wrapped in curly brackets.
{"27", "10", "34", "14", "21"}
The number of vector elements.
Create a Row Vector
Starting value.
Ending value.
Random Integers as Elements
Separate vector elements with this value.
Character before each element.
Character after each element.
Character before entire vector.
Character after entire vector.
Random Column Vector
In this example, we generate a random vertical vector with 8 elements from a wide range of one hundred to one million. We use single quotes to wrap components and put square brackets before and after the vector.
[
'265165'
'776705'
'604019'
'574885'
'940191'
'521704'
'392172'
'530477'
]
The number of vector elements.
Create a Column Vector
Starting value.
Ending value.
Random Integers as Elements
Separate vector elements with this value.
Character before each element.
Character after each element.
Character before entire vector.
Character after entire vector.
Random Rational Number Vector
This example generates a row vector with 30 decimal numbers as its components. Each component is in the range [-5, 5] and has three digits in the decimal part. It puts each vector element between a pair of angle brackets and joins them together without putting any extra characters between the elements.
<-0.388><1.225><4.285><-2.738><-4.644><-4.065><-2.890><-1.657><-4.786><-1.748><3.116><1.620><-3.592><-2.470><-3.740><0.731><1.513><2.168><-4.594><3.786><3.171><-0.777><-2.206><1.948><-1.865><1.463><-1.102><2.917><-2.356><2.969>
The number of vector elements.
Create a Row Vector
Starting value.
Ending value.
Random Decimal Fractions as Elements
If you're generating fractions, what's their precision?
Separate vector elements with this value.
Character before each element.
Character after each element.
Character before entire vector.
Character after entire vector.

How Does This Random Vector Generator Work?

This random vector generator works entirely in your browser and is written in JavaScript. First, it checks if start and end values (vector element range; specified in the options) are valid and then repeatedly uses the formula Math.random() * (end - start) + start to generate vector coordinates. If the coordinates are integers, then it also Math.floor()s them. It stores the coordinates in an array randVect that is of size length (vector length; specified in options). Before push()ing each random element to the randVect array it wraps it in before-elem and after-elem characters (symbols that get added before and after each vector element). When the randVect.length reaches the length value, it converts all vector components to a string by using the join(separator) function. If a row vector is generated, it uses the separator from options, but if it's a column vector, then the separator is set to the \n (newline) symbol. Right before printing the string to the screen, it also adds the before-vect and after-vect (symbols that get added before and after the entire vector; specified in options) to the string.

Created by Browserling

This random vector generator was created by me and my team at Browserling. Behind the scenes, it's actually powered by our programmer tools that are used by millions of people every month. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!

Secret message: If you love my tools, then I love you, too! Use coupon code TOOLLING to get a discount at my company.