Difference between N[CDF[NormalDistribution[m,s],x]] and CDF[NormalDistribution[m,s],x]? - wolfram-mathematica

I'm new to Mathematica and I am struggling with the following problem:
If I evaluate the expression N[CDF[NormalDistribution[m,s],x]] for m=12, s=25 and x=10, i get 0.468119 (=the value I would expect), however, if I evaluate the expression CDF[NormalDistribution[m,s],x] for the same x,m,s, i get 0.324195.
I checked the documentation for Mathematica and I cannot spot the difference except that N[..] returns the numerical value of the expression inside the brackets.
Any ideas? Perhaps its soo simple but i don't see it..
Thank you

Related

Azure ADF expression that returns either an existing array, or an empty array, based on a bool

I have a boolean expression: equals(myStringValue, targetStringValue)
I have an array expression which might or might not be valid, depending on the boolean condition myArrayExpression.
I want to write:
if(
equals(myStringValue, targetStringValue),
myArrayExpression,
?????
)
where ????? is an expression that returns an empty array.
Naturally, this is an XY-problem.
I definitely want to know how to do this directly, because understanding how this language works well is important to me. But if you want to know about the XY problem, it's over here: Azure ADF GetMetadata childItems if folder might not exist
Defining an array variable, with no default value, and then referencing that does work.
But seems very sad - now we've got an extra variable floating around for no reason :(
You can use if (x, Y, skip(createArray(''), 1))

Depth First Search Prolog

I'm trying to solve a water, jug problem (one 7L, one 4L, get 5L in the 7L jug) using dept first search. However something keeps going wrong whenever I try to get a new state back from one of my actions.
Prolog Code
I can't figure out what is going wrong, this is what the output looks like after trace:
enter image description here
Thanks in advance for any help!
You should copy and paste your code into your question; we cannot copy and paste it from your images, which makes it more work to help you, which in turn makes it less likely that we will help.
Some problems I noticed anyway:
Your first rule for go_to_goal/3 does not talk about the relation between ClosedList and Path. You will compute the path but will never be able to communicate it to the caller. (Then again, you also ignore Path in solve/0...) If your Prolog system gives you "singleton variable" warnings, you should never ignore them!
You are using the == operator wrong. The goal State == (5, X) states that at the end you are looking for a pair where the first component is 5 (this part is fine) and the second component is an unbound variable. In fact, after your computations, the second component of the pair will be bound to some arithmetic term. This comparison will always fail. You should use the = (unification) operator instead. == is only used rarely, in particular situations.
If you put a term like X+Y-7 into the head of a rule, it will not be evaluated to a number. If you want it to be evaluated to a number, you must use is/2 in the body of your rules.
Your most immediate problem, however, is the following (visible from the trace you posted): The second clause of go_to_goal/3 tries to call action/2 with a pair (0, 0) as the first argument. This always fails because the first argument of every clause of action/2 is a term state(X, Y). If you change this to state(0, 0) in go_to_goal/3, you should be able to make a little bit of progress.

Getting SWI-Prolog to convert Literal to number

It will be quite a miracle if someone could help with the following...
I'm using SWI-Prolog to perform queries in a triples RDF file. The values can be queried, but instead of just a number, the word Literal shows up in front of them (e.g [literal(500000)] shows up for the value 500000). Now, the problem arises when I have a list of numbers that I want to add. I try to convert these Literals into atoms so that Prolog can recognize them as numbers, but get the following error
ERROR: atom_number/2: Type error: atom' expected, found [literal(500000)]'
Any clues would be appreciated. Thanks.
Just use unification to get the number. For instance
?- [literal(500000)] = [literal(N)].
N = 500000.

Treat # as text in ToExpression Mathematica

I have to run ToExpression["Test#test"] and I want to return test#test, but the
function always return Test[test].
I tried to Unprotect, Clear, ClearAll, Remove ["#"] or [#], but it doesn't work.
Any ideas?
Test#test and Test[test] are two different notations for the very same Mathematica expression. If you convert the string "Test#test" to a Mathematica expression, any information about how it was entered is lost---only the expression structure is retained.
You should tell us why you want to "return test#test", as you said. It seems to me you have some serious confusion about how Mathematica works. Just explain what you want to achieve.

Correct use of findall/3, especially the first template argument

i know there is a build-in function findall/3 in prolog,
and im trying to find the total numbers of hours(Thrs) and store them in a list, then sum the list up. but it doesnt work for me. here is my code:
totalLecHrs(LN,THrs) :-
lecturer(LN,LId),
findall(Thrs, lectureSegmentHrs(CC,LId,B,E,THrs),L),
sumList(L,Thrs).
could you tell me what's wrong with it? thanks a lot.
You need to use a "dummy" variable for Hours in the findall/3 subgoal. What you wrote uses THrs both as the return value for sumList/2 and as the variable to be listed in L by findall/3. Use X as the first argument of findall and in the corresponding subgoal lectureSegmentHrs/5 as the last argument.
It looks like the problem is that you're using the same variable (Thrs) twice for different things. However it's hard to tell as you've also used different capitalisation in different places. Change the findall line so that the initial variable has the same capitalisation in the lectureSegmentHrs call. Then use a different variable completely to get the final output value (ie the one that appears in sumList and in the return slot of the entire predicate).
You need to use a different variable because Prolog does not support variable reassignment. In a logical language, the notion of reassigning a variable is inherently impossible. Something like the following may seem sensible...
...
X = 10,
X = 11,
...
But you have to remember that , in Prolog is the conjunction operator. You're effectively telling Prolog to find a solution to your problem where X is both 10 and 11 at the same time. So it's obviously going to tell you that that can't be done.
Instead you have to just make up new variable names as you go along. Sometimes this does get a bit annoying but it's just goes with the territory of a logical languages.

Resources