Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Put random ones in a zero matrix

Subject: Put random ones in a zero matrix

From: Alex

Date: 12 Jan, 2012 16:04:08

Message: 1 of 4

Dear all I have a matrix which is filled only with zeros.

I would like to put ones into specific X random-points (X is a variable also) ones.

The random X numbers should be coming from gaussian function.

Could you please help me if there is something like that in R?

B.R
Alex

Subject: Put random ones in a zero matrix

From: Bruno Luong

Date: 12 Jan, 2012 16:56:07

Message: 2 of 4

"Alex " <alaios@yahoo.com> wrote in message
> [snip]
> Could you please help me if there is something like that in R?

Sorry but you post to the wrong newsgroup, here we are dealing with MATLAB.

Bruno

Subject: Put random ones in a zero matrix

From: Subramanian

Date: 12 Jan, 2012 19:20:25

Message: 3 of 4

On Jan 12, 8:04 am, "Alex " <ala...@yahoo.com> wrote:
> Dear all I have a matrix which is filled only with zeros.
>
> I would like to put ones into specific X random-points (X is a variable also)  ones.
>
> The random X numbers should be coming from gaussian function.
>
> Could you please help me if there is something like that in R?
>
> B.R
> Alex

Hi Alex,

Have you looked at using the Acceptance - Rejection method to select a
random number that is distributed according to a Gaussian? i.e.
generate a randon number x (x could have uniform distribution) and
calculate y=f(x) where f is a gaussian. f(x) has a maximum value in
the stated interval over which x varies and f is defined. Generate
another random number, say m. Compare y vs m. If m < y(x) then accept
x else reject x. Hope this helps

Subject: Put random ones in a zero matrix

From: Roger Stafford

Date: 12 Jan, 2012 20:51:08

Message: 4 of 4

"Alex " <alaios@yahoo.com> wrote in message <jen09o$830$1@newscl01ah.mathworks.com>...
> Dear all I have a matrix which is filled only with zeros.
> I would like to put ones into specific X random-points (X is a variable also) ones.
> The random X numbers should be coming from gaussian function.
- - - - - - - - -
  I think you should explain your problem again in much greater and more careful detail, Alex. You say "put ones" but also refer to "numbers should be coming from gaussian function". Numbers coming from such a gaussian distribution lie in a continuum with an infinite range and cannot possibly refer to discreet locations within your matrix and they also cannot be the "ones" values you specify that are to be placed there. You leave us greatly puzzled! The question is what values are to be placed in the matrix and where are these to go?

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us