-1

I need to construct diagonal matrix with conditional number is 997.49.45

so I need to generate a random vector uniformly distributed in (0,1) with max_value / min value approximate 997.4945.

I really confused these day. Is there any methods for problem?

Nuhyen
  • 11
  • 1
    Check the accepted answer for this question: https://stackoverflow.com/questions/65037999/function-in-matlab-to-draw-samples-from-uniform-distribution That question is not really identical to yours, but the answer should help you anyway. – giusti May 20 '23 at 18:36
  • 1
    What do you mean by "random vector uniformly distributed in (0,1)"? If that means each entry is independent and uniformly distributerd on (0,1), that's incompatible with the condition on max / min. If you mean for the _vector_ to be uniformly distributed among all vectors with that max / min value and entries on (0,1), you can maybe use something similar to [this](https://stackoverflow.com/a/8068956/2586922), but that's probably more difficult – Luis Mendo May 20 '23 at 22:23
  • You haven't specified the size of the vector, i.e., how many random numbers there are. Min and max are order statistics, and their distribution depends on sample size. For example, with X1,...,Xn ~Uniform(0,1) the probability of getting a min value less than 0.05 is substantially higher for n = 100 than for n = 3. – pjs May 24 '23 at 20:21

1 Answers1

0

1.-

N=1000;   % amount samples
a1=1e4
b1=9974945
x1=1/(a1*b1)*randi([a1 b1],1,N);

x1 is a random vector uniformly distributed within (0,1) and the max/min ratio meets the requested roof of 997.4945.

2.-

Check

max(x1)/min(x1)

May be a single run does no show the max/min roof of 997.4945 but the larger N and the more runs taken the higher the probability to obtain true

max(x1)/min(x1)==997.4945

try

max(x1)/min(x1)==997.494

or

max(x1)/min(x1)==997.49

To eventually meet a max/min roof no far from the requested 997.4945

3.-

Imposing a max/min roof on a uniform distribution implies modfying the probability density function.

To satisfy the requested max/min roof yet keeping the samples uniformly scattered within an interval, it means that some values that are part of the original uniform distribution have to be ignored.

John BG
  • 690
  • 4
  • 12
  • If I understand the question correctly, it specifies a ratio max/min, not separate max and min values. Also, your distributions are discrete, not continuous, which again doesn't seem to be what the OP wants – Luis Mendo May 20 '23 at 22:27
  • x1 x2 look discrete but increasing a1 b1 a2 b2 accordingly one can make it look like continuous down to as many decimals as required to such purpose, which is what Nuhyen is looking for. – John BG May 20 '23 at 22:31
  • @John Many thanks for your comment. Actually, I need the diagonal elements are uniformly distributed in (0,1) with condition number is 997.4945. And using your code give results **997**. I wonder to know if it okay? – Nuhyen May 21 '23 at 05:36
  • @Nuhyen I have changed my answer and added some clarifications. – John BG May 21 '23 at 17:48
  • @JohnBG I used your code. It results `>> max(x1)/min(x1) ans = 602.1179` I think there may be an error somewhere. However, for my project, **997** might be okay. But I want to get condition number example **4448807.0435** when max value is known equal to 100. Is there any method to solve that? Again, many thanks for your help!! – Nuhyen May 23 '23 at 17:18
  • ok, let me have a look, I queue your query again, I come back when I have something. At least now you see you can use randi to set up a uniform distribution within any range, including decimals. Back when I get to something. – John BG May 24 '23 at 13:23