Results 1 to 4 of 4

Math Help - Generating random vectors

  1. #1
    Newbie
    Joined
    Aug 2013
    From
    Bratislava Slovakia
    Posts
    3

    Generating random vectors

    Hey folks,

    I need an algorithm to generate random vectors. Restriction on vectors $x=(x_1,\ldots,x_n)$ are as follows:

    a) $x_1 + x_2 + \ldots + x_n$ = 0 so they lie in an n-1 dimensional hyperplane going through zero.
    b) $x_i \in [-1,1] \forall i$
    c) The density is uniform, e.g. each vector satisfying conditions a) and b) is picked with equal probability.

    Example: $(1,-1/2,-1/2)$ and $(0,0,0)$ are both OK as long as they are generated with the same probability.

    Thanks
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor

    Joined
    Apr 2005
    Posts
    15,545
    Thanks
    1394

    Re: Generating random vectors

    Use whatever random number generator you like to get values for x_1, x_2, ..., x_{n-1} between -1 and 1, then calculate x_n= -x_1- x_2- x_3- \cdot\cdot\cdot - x_{n-1}.
    Last edited by HallsofIvy; August 29th 2013 at 02:56 PM.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Aug 2013
    From
    Bratislava Slovakia
    Posts
    3

    Re: Generating random vectors

    Sorry, but your method does not neccessarily guarantee that  $x_n \in [-1,1]$ is satisfied, for example if all your draws from $1$ to $n-1$ are equal to one and $n\geq 3$.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Aug 2013
    From
    Bratislava Slovakia
    Posts
    3

    Re: Generating random vectors

    @HallsofIvy any other ideas? I would be really thankful since I think this one is easy and it's just me who's stupid
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Generating Random Variables
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: March 14th 2010, 05:49 PM
  2. Generating random variables
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: January 30th 2010, 11:41 PM
  3. Generating gamma random variables
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: January 27th 2010, 05:46 AM
  4. Generating Random Variables
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: November 16th 2006, 08:02 AM
  5. Replies: 3
    Last Post: October 20th 2005, 12:09 AM

Search Tags


/mathhelpforum @mathhelpforum