debugging: is it really harder to debug random algorithms?

I followed this answer in a slightly different direction, not from a debug, but from a test perspective:

Usually, a pure function has a very simple configuration:

Same entry, same result.

That makes it very easy to define appropriate test cases: select a set of standard test values ​​and some of special interest (depending on what your function does), write your test methods for it, comparing what the function returns with What I expected is to return. This provides you with a solid set of test methods that you can execute whenever you make changes.

Once you start to have randomness in your methods, you encounter this problem:

The same entry, many possible values.

Now you need to know ALL the possible values ​​that your random function could return for a given entry, and test them. And depending on what your random function does, that is simply unfeasible (due to many options that you need to add manually or programmatically), or directly impossible.

Suddenly, the amount of effort to create a solid set of tests increased dramatically, at which point it usually skips directly.

How would we avoid this?

To avoid this while writing your algorithms, you would encapsulate the piece of randomness. He would try to place the fragment that really causes the random part within his own object, outside the algorithm. Now you can really make funof that object during its test set, basically fixing the values ​​that the "randomized" object would return. It is not ideal, and does not cover all scenarios, but neither does almost any test. The effort to create your test suite increased slightly, since "randomness" is gone now, and you can treat it as a normal and pure function for testing purposes.

Similar principles apply to the manual debugging of a function: most of the time it is not really known what random value the algorithm generated and, therefore, it is difficult to recreate what exactly happened in the function that broke it. That makes manual debugging very difficult.

pr.probability: random set and stop properties

Leave $ ( Omega, mathcal {F}, mathbb {P}) $ be a space of probability Let $ S $ be an accounting set, and we define a family of sub-$ sigma $-algebras $ (F_A) _ {A subseteq S} $ such that $ A subseteq B Rightarrow mathcal {F} _A subseteq mathcal {F} _B $ for all $ A, B subsete S $. We define a random subset $ zeta $ from $ S $ be a mapping $ zeta: Omega to mathcal {P} (S) $ such that $ { zeta subseteq A } in mathcal {F} $ for all $ A subseteq S $. Finally we say that $ S $ it's a stop set if $ { zeta subseteq A } in mathcal {F_A} $ for all $ A subseteq S $. I have two problems:

  1. Show that $ zeta $ it's a stop game $ Leftrightarrow $ $ { zeta = A } in mathcal {F} _A $ for all $ A subseteq S $.
  2. For two stop games $ zeta $ Y $ eta $, They are $ zeta cup eta $ Y $ zeta cap eta $ Necessarily stopping sets too?

For the first, the forward direction is direct as $ S $ is an accountant then $ A $ is an accountant We can simply observe that $ { zeta = A } = { zeta subseteq A } setminus bigcup_ {a in A} { zeta subseteq A setminus {a } } in mathcal { F} _A $. However, the opposite is much less direct, since the number of subsets of $ A $ it can be uncountable (e.g. $ A = S $) As $ sigma $-Algebra only guarantees the closure of accounting unions, I am not sure how to proceed.

Second, the first part is also simple, with the observation that $ { zeta cup eta subseteq A } = { zeta subseteq A } cap { eta subseteq A } $. I know that the answer to the second part is false, but I'm not sure how to build an explicit counterexample.

Thanks in advance.

Is there a way to create a view filter to show drupal users whose names are meaningless / random characters?

I am trying to purge my drupal site from spam users. I have set up a page where I can filter users by email address, name, creation date, etc. I would like to have a filter that verifies the name field to see if it is a real name or just a collection of random characters.

Does anyone know a way to do this?

network – Why "what is my IP" shows a strange / random IP and not the fiber IP of my home?

When I try ifconfig.co or whatismyip.com on my MacOS 10.4 I get a completely unknown IP address and it even changes every day or two.

I tried Safari, Brave, Firefox and even did it curl ifconfig.co from the terminal and all show the same IP, currently somewhere in the USA. UU. (and I'm not near the US) But, as I said, it occasionally changes to other IPs.

I don't have any proxy configured (marked in both network settings and Firefox), the default route that shows netstat -rn My home router points out, but somehow my traffic is routed through these strange IP addresses.

I don't know any VPN that runs either.

What is causing it? What should I verify?

python 3.x – How to draw a random sample of a normal distribution within a numpy range

I want to get a list of random values ​​between 0 and 365 that come from a normal distribution. This is the code I have but it does not produce a normal and rather unimodal distribution.

f=np.random.randint(low=0, high=365, size=100000)
sns.distplot(f);

How can I get X values ​​between 0 and 365 of a normal distribution?

pr.probability – Independence in random orthogonal matrix

Leave $ U in mathbb {R} ^ {n times n} $ be a uniform random orthogonal matrix. Leave $ L in mathbb {R} ^ {m times m} $ be the submatrix of $ U $ in the upper left corner Leave
$$ L = (a_1, a_2, …, a_m) = begin {pmatrix}
b_1 ^ T \
vdots \
b_m ^ T
end {pmatrix} $$

where $ a_j $ they are column vectors and $ b_i ^ T $ they are row vectors of $ L $. Define
$$ A = begin {pmatrix}
| a_1 | ^ 2 \
vdots \
| a_m | ^ 2
end {pmatrix}, B = begin {pmatrix}
| b_1 | ^ 2 \
vdots \
| b_m | ^ 2
end {pmatrix}, C = begin {pmatrix}
frac {b_1 ^ T} { | b_1 |} \
vdots \
frac {b_m ^ T} { | b_m |}
end {pmatrix} $$

where $ | | $ is the Euclidean norm It can be shown that $ frac {b_i} { | b_i |} $ is independent of $ | b_i | $ and it seems intuitive that there are more independence relations like this. The questions are:

They are $ A $ Y $ C $ Independent? They are $ B $ Y $ C $ Independent?

Find the expectation and variance of the "V" shape number in the random chart

P: There are n vertices where each pair of vertices is connected by an edge independently with probability p. Find the expectation and variance of the number of the form of "V" in the random graph since "V" is formed by 3 vertices {i, j, k} where there are exactly 2 edges between them.


First I let N = V shape number is the random graph and discovered that $ {E (N)} $ $ {=} $ $ {n choose 3} $$ {3 (p ^ 2) (1-p)} $.

$ {Var (n) =} $ $ sum _ {{(i, j, k)}} Var (Y) + sum _ {{(i, j, k) neq (i & # 39 ;, j & # 39 ;, k & # 39 ;)}} Cov (Y, Y & # 39; PS

where Y is the indicating function that there is a V shape in a random graph with vertices i, j, k.

$ {Var (Y) = E (Y ^ 2) + E (Y) ^ 2 = 3 (p ^ 2) (1-p) -9 (p ^ 4) (1-p) ^ 2} $

$ {Cov (Y, Y & # 39;) = E (Y {i, j, k }, Y {i, j, k & # 39; }) – E (Y {i, j, k }) E (Y {i, j, k & # 39; }) = 3 (p ^ 3) (1-p) ^ 2-9 (p ^ 4) (1-p) ^ 2} $

Therefore i have $ {Var (N) =} $ $ {n choose 3} $$ {(3 (p ^ 2) (1-p) -9 (p ^ 4) (1-p) ^ 2) +} $ $ {n choose 2} {n-2 choose 2} $$ {(2) (3 (p ^ 3) (1-p) ^ 2-9 (p ^ 4) (1-p) ^ 2) $

Can anyone help me see if my answer is correct? Thank you.

Algorithm for traveling to the upper right corner in a room with random walls inside

First of all, I hope you have a good day.
Now about the problem.
A robot, say Steve, is in the lower left corner of a rectangular room. Your goal is to travel to the upper left corner of the room. There are random walls present in the room. There is always a way to the corner.
Steve can do the following:

  1. Move along
  2. Turn left, right and back.
  3. Detect if there is a wall in front or not.
  4. Detect if he is looking left, right, up or down.
  5. Place / collect a diamond in / from the slot in which it is located.
  6. Detect if there is a diamond where it stands.
  7. Steve has infinite numbers of diamonds.
  8. Steve can't count.

What I have thought so far is to use the right-handed method with which Steve will always reach the upper right corner, but detecting it is the main problem, since there may be other places in the room with walls to the right and up. Consider this case, for example:An example of a room

"S" represents Steve. Your destination is (10, 8), but as we can see, there are 7 other places in the room that can be confused with the destination simply by checking the surrounding walls.

Any help is really appreciated!

PD The use of variables is prohibited 🙁

random process – Random function of the non-homogeneous Poisson process: unexpected behavior

For $ 100,000 realization of the non-homogeneous random Poisson process

proc = InhomogeneousPoissonProcess(a*x, x);
sim = Sign@(#("Values"))((-1)) & /@ Table(RandomFunction(proc, {0, 1}), 1000000) 

small part of the results has a way

Sign(Values)

(values ​​of cca 50)

I think that the random function seems not to be evaluated, because the analysis of the internal behavior of the formula

simTable = Table(RandomFunction(buyProc, {0, 1}), 1000000); 
(Transpose@{Sign@(#("Values"))((-1)) & /@ simTable, simTable}) // DeleteCases(#, {_Integer, _}) &

leads to the repeat sequence of

{Sign("Values"), RandomFunction(InhomogeneousPoissonProcess(10 t,t), {0, 1})}

This means that in several cases the function has not been evaluated at all. It is not that the random part of the results is no longer processed (the result excepted is {0 or 1, TemporalData}.

Where is the error and how to treat it?