# Re: [R] Latin Hypercube with condition sum = 1

From: Ben Bolker <bolker_at_ufl.edu>
Date: Sun, 23 Nov 2008 13:06:42 -0500

x2 <- (x-min(x))/(max(x)-min(x)) ## establishes criterion 1

```x3 <- x2/sum(x2)                 ## establishes criterion 2

```

work? I haven't thought about this very carefully, but since transformation makes min(x)=0 and max(x)=1 (and therefore sum(x)>1 -- although it won't work if length(x)<2 or var(x)==0) transformation 2 will necessarily reduce the range and therefore not violate criterion 1 ... ?

Ben Bolker

```>> Rainer M Krug <r.m.krug <at> gmail.com> writes:
>>
>>> Hi
>>>
>>> I want to du a sensitivity analysis using Latin Hypercubes. But my
>>> parameters have to fulfill two conditions:
>>>
>>> 1) ranging from 0 to 1
>>> 2) have to sum up to 1
>>>
>>  Perhaps I'm missing something, but it seems that there's
>> only one vector that satisfies these two conditions simultaneously,
>> which is x={0,1} ... ???  (Actually, technically speaking
>> you could have as many zeros as you wanted -- x = {0,0,0,1}
>> would also work -- but I don't think that's going to help much.)
>> If min(x)=0 and max(x)=1, then x must contain 0 and 1.  If x
>> contains any other non-zero values, and no negative
>> ones, then sum(x)>1 ...
```

>
> You are absolutely right - but when you look at the example, I want
> that the FINAL latin hypercube sets sum up to one, and the values
> RANGING from 0 to 1, i.e. (0.5, 0.5) would also satisfy the condition.
>
```>>   You seem to have a problem either in your definitions,
>> or in your communication of those definitions to us ...
```

>
> Probably both - but to try again:
>
> 1) values ranging between 0 and 1 (0 <= x <= 1)
> 2) all elements in one set of the lLatin Hypercube should add to one.
>
> Assuming two dimensions, (1,0) & (0,1) & (0.3, 0.7) , ... would all
> satisfy the condition 1 and 2;
>
> (0.8, 0.3) would satisfy 1, but not 2;
> (-1, 2) would satisfy 2, but not 1
>
> Hope this clarifies my question,
>
> Rainer
>
```>>  cheers
>>   Ben Bolker
>>
>> ______________________________________________
>> R-help_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> and provide commented, minimal, self-contained, reproducible code.
>>
```

>
>
>
```--
Ben Bolker
Associate professor, Biology Dep't, Univ. of Florida
bolker_at_ufl.edu / www.zoology.ufl.edu/bolker
GPG key: www.zoology.ufl.edu/bolker/benbolker-publickey.asc

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help