Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to identify if a variable, which is the result of a calculation, is Indeterminate. I was trying to do this using If[]. For example

p = Log[PDF[NormalDistribution[0, 1], 1000000.]]
If[p==Indeterminate,1,0]
If[p=="Indeterminate",1,0]

But it is not working. Could you please point me to a better strategy?

share

closed as too localized by Oleksandr R., F'x, rm -rf, belisarius, J. M. Sep 22 '12 at 2:48

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Voting to close for TL as this is directly addressed in the documentation for Indeterminate. –  Oleksandr R. Sep 12 '12 at 15:23
1  
Procrastinator, you have only one down-vote on this question, and two up-votes; that's a net gain of +8 points. I don't think this needs to be deleted. If you get a bunch of additional down-votes or if it really bothers you I can delete it; flag again if needed. –  Mr.Wizard Sep 12 '12 at 16:51

1 Answer 1

up vote 5 down vote accepted

You can use === (SameQ). Indeterminate is a special head, so that Equal (==) on it remains unevaluated:

Indeterminate == Indeterminate

(*  Indeterminate == Indeterminate *)

while

Indeterminate === Indeterminate

(* True *) 
share
    
Awesome! Thanks! I will accept the answer in 10 minutes. –  user2277 Sep 12 '12 at 15:19
3  
@Procrastinator It is a recommended practice to wait for some time for better answers to appear. Normally one can give it a day or two, but that also depends on the question. –  Leonid Shifrin Sep 12 '12 at 15:20
    
Yes, I understand. In this case, this answer solves my problem. –  user2277 Sep 12 '12 at 15:21
    
MatchQ[] could be an alternative here, methinks... –  J. M. Sep 13 '12 at 13:43
    
@J.M. Sure, MatchQ reduces to SameQ for patterns not containing blanks etc. But it seems a less direct way to me. –  Leonid Shifrin Sep 13 '12 at 13:46

This site is currently not accepting new answers.