Questions tagged [non-deterministic]

Nondeterminism refers either to a computing system where the result may be one of many specified results or to a theoretical construct in which a computing system is allowed to try many options in parallel to search for a result.

Nondeterminism has several meanings in computing. In theoretical CS, nondeterministic computations are computations that have multiple options specified at various points and allows the computing machine to choose any of them. In programming, a nondeterministic computation is one where the result may vary from run to run due to factors such as thread timing or values from external devices.

238 questions
7
votes
1 answer

Python floating point determinism

The code below (to compute cosine similarity), when run repeatedly on my computer, will output 1.0, 0.9999999999999998, or 1.0000000000000002. When I take out the normalize function, it will only return 1.0. I thought floating point operations…
6
votes
2 answers

How to cleanly convert between lists and ListT monad transformers?

I am currently writing a project where I make a heavy use of ListT monad transformer. When using plain lists, implementing nondeterminism is very easy. However once I had to convert my code to ListT, it got much more complicated 1. As a simple…
julx
  • 8,694
  • 6
  • 47
  • 86
6
votes
4 answers

What does it mean by "Non-deterministic User-Defined functions can be used in a deterministic manner"?

According to MSDN SQL BOL (Books Online) page on Deterministic and Nondeterministic Functions, non-deterministic functions can be used "in a deterministic manner" The following functions are not always deterministic, but can be used in indexed…
dance2die
  • 35,807
  • 39
  • 131
  • 194
6
votes
1 answer

Perl: Are Special Variables Thread Safe?

I was reading some questions regarding the $@ global variable and how it can be clobbered before it's even handled due to successful evals wiping it clean. But what if it gets clobbered by an error occurring in a concurrent thread? The new threads…
Louis
  • 2,442
  • 1
  • 18
  • 15
6
votes
1 answer

`amb` operator as macro or procedure?

In this page there is a comment after the post that gives a very short implementation of amb as a procedure: (define (amb-backtrack) (error "no solution found")) (define (amb . args) (call/cc (lambda (return) (let ((backtrack…
Jay
  • 9,585
  • 6
  • 49
  • 72
6
votes
2 answers

What is the default type evaluation of MonadPlus in Haskell?

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…
ManuelVS
  • 125
  • 6
6
votes
1 answer

Non-deterministic Gradient Computation

I realized that my models end up being different every time I train them, even though I keep the TensorFlow random seed the same. I verified that: Initialization is deterministic; the weights are identical before the first update. Inputs are…
Georg
  • 960
  • 2
  • 7
  • 22
6
votes
1 answer

How do I convert a list monadic function to a breadth-first search?

I just got over the hump of figuring out how to use the List monad to do nondeterministic computations. However I believe my algorithm would benefit from a breadth-first search instead of a depth-first one which you get from the List monad. Here is…
6
votes
2 answers

Using TSQL, CAST() with COLLATE is non-deterministic. How to make it deterministic? What is the work-around?

I have a function that includes: SELECT @pString = CAST(@pString AS VARCHAR(255)) COLLATE SQL_Latin1_General_Cp1251_CS_AS This is useful, for example, to remove accents in french; for example: UPPER(CAST('Éléctricité' AS VARCHAR(255)) COLLATE…
Frank Monroe
  • 1,557
  • 2
  • 13
  • 20
5
votes
1 answer

Haskell Combining non-determinism with error handling

Suppose I'm creating a simple interpreter that can throw errors, e.g. type Error = String data Term = Con Int | Div Term Term eval :: (MonadError Error m) => Term -> m Int eval (Con a) = return a eval (Div u v) = do a <- eval u b <- eval v …
Safron
  • 802
  • 1
  • 11
  • 23
5
votes
1 answer

Does F# suffer from same C# caveats on non-deterministic floating point calculation?

The result of C# floating-point code can lead to different results. This question is not about why 0.1 + 0.2 != 0.3 and the inherent imprecision of floating point machine numbers. It is rather linked to the fact that the same C# code, with the same…
Pac0
  • 21,465
  • 8
  • 65
  • 74
5
votes
2 answers

Combine ST and List monads in Haskell

Using the StateT monad transformer, I can create the type StateT s [] a, which is isomorphic to s -> [(a, s)]. Now I would prefer to use the STT monad transformer instead, as I would like to have multiple mutable variables of different types, and…
dremodaris
  • 358
  • 1
  • 9
5
votes
1 answer

Unrelated code changes results of calculation

We have some code that is giving unexpected results on some machines. I've narrowed it down to a simple example. In the linqpad snippet below, the methods GetVal and GetVal2 have essentially the same implementation, although the former also includes…
Rob
  • 4,327
  • 6
  • 29
  • 55
5
votes
1 answer

Data structures with nondeterministic components in Coq

I tried to model a less naive monadic encoding of non-determinism (less naive than MonadPlus and common lists) in Coq that is often used in Haskell; for example the encoding for lists looks like data List m a = Nil | Cons (m a) (m (List m…
ichistmeinname
  • 1,480
  • 10
  • 19
5
votes
2 answers

Why the LAG function in T-SQL is non-deterministic?

I'm trying to use LAG in T-SQL to compute some lagging features. I got a little worried when the LAG reference page says that this function is non-deterministic. The reference page on function determinism says that "specifying an ORDER BY clause in…
hlu
  • 347
  • 1
  • 2
  • 12
1 2
3
15 16