non-deterministic

Deterministic python script behaves in non-deterministic way

故事扮演 提交于 2019-12-05 14:40:18
问题 I have a script which uses no randomisation that gives me different answers when I run it. I expect the answer to be the same, every time I run the script. The problem appears to only happen for certain (ill-conditioned) input data. The snippet comes from an algorithm to compute a specific type of controller for a linear system, and it mostly consists of doing linear algebra (matrix inversions, Riccati equation, eigenvalues). Obviously, this is a major worry for me, as I now cannot trust my

Deterministic python script behaves in non-deterministic way

♀尐吖头ヾ 提交于 2019-12-04 00:48:29
I have a script which uses no randomisation that gives me different answers when I run it. I expect the answer to be the same, every time I run the script. The problem appears to only happen for certain (ill-conditioned) input data. The snippet comes from an algorithm to compute a specific type of controller for a linear system, and it mostly consists of doing linear algebra (matrix inversions, Riccati equation, eigenvalues). Obviously, this is a major worry for me, as I now cannot trust my code to give me the right results. I know the result can be wrong for poorly conditioned data, but I

Why is the non-deterministic choice function in Curry's std lib not defined straightforwardly but rather with a helper 2-argument function?

試著忘記壹切 提交于 2019-12-03 23:29:52
Consider a function choose in Curry programming language with the specification that " (choose xs) non-deterministically chooses one element from the list xs ". I'd implement it straighforwardly through two alternative non-deterministic rules: choose :: [a] -> a choose x:_ = x choose _:xs = choose xs But in /usr/lib/curry-0.9.11/Success.curry from Muenster Curry Compiler , it is defined with a helper function: choose (x:xs) = choosep x xs where choosep x [] = x choosep x (_:_) = x choosep _ (x:xs) = choosep x xs What could be the advantages (if any) of the definition from the compiler supplied

What is the benefit of using exponential backoff?

本秂侑毒 提交于 2019-12-03 15:54:24
问题 When the code is waiting for some condition in which delay time is not deterministic, it looks like many people choose to use exponential backoff, i.e. wait N seconds, check if the condition satisfies; if not, wait for 2N seconds, check the condition, etc. What is the benefit of this over checking in a constant/linearly increasing time span? 回答1: This is the behavior of TCP congestion control. If the network is extremely congested, effectively no traffic gets through. If every node waits for

Why is concurrent haskell non deterministic while parallel haskell primitives (par and pseq) deterministic?

微笑、不失礼 提交于 2019-12-03 15:14:12
问题 Don't quite understand determinism in the context of concurrency and parallelism in Haskell. Some examples would be helpful. Thanks 回答1: When dealing with pure values, the order of evaluation does not matter. That is essentially what parallelism does: Evaluating pure values in parallel. As opposed to pure values, order usually matters for actions with side-effects. Running actions simultaneously is called concurrency . As an example, consider the two actions putStr "foo" and putStr "bar" .

What is the benefit of using exponential backoff?

拈花ヽ惹草 提交于 2019-12-03 06:12:46
When the code is waiting for some condition in which delay time is not deterministic, it looks like many people choose to use exponential backoff, i.e. wait N seconds, check if the condition satisfies; if not, wait for 2N seconds, check the condition, etc. What is the benefit of this over checking in a constant/linearly increasing time span? This is the behavior of TCP congestion control. If the network is extremely congested, effectively no traffic gets through. If every node waits for a constant time before checking, the traffic just for checking will continue to clog the network, and the

How should I Test a Genetic Algorithm

落爺英雄遲暮 提交于 2019-12-03 00:20:39
问题 I have made a quite few genetic algorithms; they work (they find a reasonable solution quickly). But I have now discovered TDD. Is there a way to write a genetic algorithm (which relies heavily on random numbers) in a TDD way? To pose the question more generally, How do you test a non-deterministic method/function. Here is what I have thought of: Use a specific seed. Which wont help if I make a mistake in the code in the first place but will help finding bugs when refactoring. Use a known

I do not understand the concept of Non Deterministic Turing Machine [closed]

守給你的承諾、 提交于 2019-12-02 21:51:21
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. I do not the understand the concept of Non Deterministic Turing Machine . I guess I understand the term Non deterministic algorithm : (nondeterministic algorithm is an algorithm that can exhibit different behaviors on different runs, as opposed to a deterministic algorithm.) So the algorithm could be like : a = fromSomeAlgo(); if(a > foo) stateA(); else stateB(); But for non-deterministic turing machine I read , it can

Indeterministic sets in Python 2 and 3

元气小坏坏 提交于 2019-12-02 13:16:09
Python 2 Sets are collections of unordered values. If I construct a set via a set literal, e.g. s = {'a', 'b', 'c'} and then print it, I get the elements in some scrambled order. However, it seems that in Python 2.7, the above example always results in the same ordering: print(s) # set(['a', 'c', 'b']) in Python 2.7 How does Python 2.7 decide on this ordering? Even the hashes of 'a' , 'b' and 'c' are not in the order produced. Python 3 In Python 3.x (including 3.6 where dict keys are ordered) the resulting order seems to be random, though always the same within a given Python process. That is,

What is the default type evaluation of MonadPlus in Haskell?

我们两清 提交于 2019-11-29 14:08:27
I have the following code: import Control.Monad coin :: MonadPlus m => m Int coin = return 0 `mplus` return 1 If I evaluate coin :: Maybe Int on the interpreter, it prits Just 0 . That's normal because of the implementation of Maybe as instance of MonadPlus. If I evaluate coin :: [Int] on the interpreter, it prints [0, 1] , because the implementation of mplus on list is an append . But if I evaluate coin , without any type decorators, it prints 0 . Why? What type does the interpreter 'converts' coin to evaluate it? This code is extracted from: http://homes.sice.indiana.edu/ccshan/rational