comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: BEGINNER ASKS FOR HELP!!!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: BEGINNER ASKS FOR HELP!!! [message #10944 is a reply to message #10943] Sat, 31 January 1998 00:00 Go to previous message
Dr. G. Scott Lett is currently offline  Dr. G. Scott Lett
Messages: 14
Registered: February 1998
Junior Member
Edoardo "Dado" Marcora wrote:

> Dear Sirs,
>
> I've just started using IDL 5 and I would like to solve this problem I've
> encountered.
>
> I need to create a RANDOM square matrix that contains only three numbers 0,
> 1, and (-1). There are two constraints though. I would like to tell the
> program before it creates this matrix what the (at least approximate) RATIO
> of 1 / (-1) should be and HOW MANY (at least approximately) 1 and (-1)
> (total) are on each row of the matrix.
>
> For example, the input by the user would be:
>
> NUMBER OF ELEMENTS PER ROW e.g., 6
>
> RATIO OF 1 / (-1) e.g., 0.5 (at the level of the matrix not of the row)
>
> NUMBER OF 1 AND (-1) (total) IN EACH ROW e.g., 3 (for example 0 0 0 1 1 -1)
>
> I do not need the ratio and number of |1| per row to be exact, also an
> approximation it's good.
>
> Thanx for your help,
>
> Dado

Dear Dado,
This isn't the entire function you want, but it should help you write one.


A = randomu( seed, 6, 6 )
high = float( 3 ) /6
low = high * 0.5
neg = where( A lt low, countLow )
pos = where( A ge low and A lt high, countHigh )
B = intarr( 6, 6 )
if countLow gt 0 then B[ neg ] = -1
if countHigh gt 0 then B[ pos ] = 1





--
========================
Dr. G. Scott Lett
slett@holisticmath.com
http://holisticmath.com/
========================
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: REAL DATA
Next Topic: Fun with CDF_ENCODE_EPOCH

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 17:47:58 PDT 2025

Total time taken to generate the page: 1.44738 seconds