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

Home » Public Forums » archive » Re: combinatory analysis with restrictions
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: combinatory analysis with restrictions [message #41749] Wed, 08 December 2004 22:41 Go to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
fleduc@lycos.com (Francois) writes:

> Hello,
>
> Considering 3 variables (a,b,c) that can take 11 discrete values
> between 0 and 1: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9,
> 1.0]

Why don't you make a 2D array of (11,11) corresponding to the sum of
all possible values of A and B?

For each value of (A+B), the value of C is immediately determined as
1-(A+B), or it does not exist if (A+B)>1. Thus, for each entry in the
matrix, you can read off A and B from the column and row labels, and C
from 1-(A+B).

Good luck,
Craig

aa = lindgen(11) # (lonarr(11)+1) ;; A-only matrix
bb = (lonarr(11)+1) # lindgen(11) ;; B-only matrix
cc = 10-(AA+BB)
wh = where(cc GE 0)
a = wh MOD 11 & b = wh/11 & c = cc(wh)

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: combinatory analysis with restrictions [message #41750 is a reply to message #41749] Wed, 08 December 2004 21:29 Go to previous messageGo to next message
Y.T. is currently offline  Y.T.
Messages: 25
Registered: December 2004
Junior Member
If I had to do it once, I'd brute-force it:

IDL> for a=0.,1.,.1 do for b=0.,1.,.1 do for c=0.,1.,.1 do $
IDL> if a+b+c eq 1. then print,a,b,c

or some such.

If I had to do this many times, I'd consider pre-filling an array
vaguely like this

IDL> r=intarr(11,11,11)
IDL> for i=0,10 do for j=0,10 do for k=0,10 do $
IDL> if i+j+k eq 10 then r[i,j,k]=1

and then later simply looking up r[a*10,b*10,c*10] ...
cordially

Y.T.

--
Remove YourClothes before you email me.
Re: combinatory analysis with restrictions [message #41985 is a reply to message #41749] Thu, 09 December 2004 07:44 Go to previous messageGo to next message
fleduc is currently offline  fleduc
Messages: 7
Registered: December 2004
Junior Member
Thanks for the answer.
But what is considering five variables ?

F.
Re: combinatory analysis with restrictions [message #42037 is a reply to message #41985] Fri, 10 December 2004 18:15 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
fleduc@lycos.com writes:
> Thanks for the answer.
> But what is considering five variables ?

I don't know what you mean. You didn't ask about five variables, only
three: A, B, C.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Help with Nested FOR Loop
Next Topic: iplot

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

Current Time: Wed Oct 08 18:38:14 PDT 2025

Total time taken to generate the page: 0.00424 seconds