Questions tagged [nan]

NaN is an abbreviation for "Not a Number". NaN is sometimes not equal to itself.

NaN (Not a Number) is a value of the numeric data type representing an undefined or unrepresentable value, especially in floating-point calculations. Systematic use of NaNs was introduced by the IEEE 754 floating-point standard in 1985, along with the representation of other non-finite quantities such as infinity.

A common feature of NaN in many programming languages is that NaN is not equal to itself.

4290 questions
2
votes
1 answer

Python: change numpy array with NaNs to array with numbers and '--'

I have a numpy array with some floats and some nans: a = [ 8.08970226 nan nan 8.30043545 nan nan nan nan] I want to convert it to an array (for printing in Latex) to the mixed form: a = ['8.08970226', '--', '--', '8.30043545', '--', '--',…
dcnicholls
  • 391
  • 1
  • 5
  • 15
2
votes
2 answers

Image Processing Issue: Fill NaNs in image, which mostly consists of NaNs

I have a dataset / image DD like the one in this image: (by the way: is there a way of uploading small data sets here, so that you can actually work with the same data I use, without having to put them in the code?) Colored pixels in the image…
TheodorBecker
  • 249
  • 1
  • 17
2
votes
2 answers

Cellfun is reordering my matrix when I try to clear the NaN's from it

I am having some trouble with Matlab right now. I am currently trying to remove all the NaN's from a large Cell Array I have 3806 x 122. I have been looking at solutions from similar problems, and I came up with. data(cellfun(@(x)…
Jon Bot
  • 87
  • 6
2
votes
1 answer

Which is the best practice for initializing a double in C++?

I'm wandering which is the best practice to initialize a double. It is better to initialize it to 0.0 or NaN? And why?
2
votes
1 answer

Wrong result from mean(x, na.rm = TRUE)

I want to compute the mean, min and max of a series of Managers returns, as follows: ManagerRet <-data.frame(diff(Managerprices)/lag(Managerprices,k=-1)) I then replace return = 0 with NaN since data are extracted from a database and not all the…
Lorenzo Rigamonti
  • 1,705
  • 8
  • 25
  • 36
2
votes
1 answer

JavaScript: Why is NaN !== NaN?

What is the reasoning? I believe this is the only value not equal to itself in JavaScript.
po.studio
  • 4,007
  • 5
  • 25
  • 37
2
votes
0 answers

cvCalibrateCamera2 returns matrix with NaN-elements

I'm trying to do a camera calibration using cvCalibrateCamera2() but run into a strage problem: the returned intrinsic_matrix and distortion_coeffs contain invalid floats (=NaN). That's what I'm doing (the break's are responsible for leaving this…
Elmi
  • 5,899
  • 15
  • 72
  • 143
2
votes
2 answers

Why in J 0%0 is defined, but _%_ gives a NaN error?

I J, 0%0 (zero divided by zero) gives 0 as an answer. However, _%_ (infinity divided by infinity) gives a NaN error? Why isn't it defined, while 0%0 is?
Charles Brunet
  • 21,797
  • 24
  • 83
  • 124
2
votes
3 answers

Why is IsNaN(x) different from x == NaN where x = NaN

Why are these two different? var x = NaN; //e.g. Number("e"); alert(isNaN(x)); //true (good) alert(x == NaN); //false (bad)
peter n
  • 1,210
  • 13
  • 18
2
votes
1 answer

Why is SIGAR returning NaN or zero randomly

Trying to run SIGAR rapidly to get a number of hardware metric samples, and I see this behavior: val sig: Sigar = new Sigar() val steady_cpu: Double = (for (i <- 1 to 100) yield sig.getCpuPerc().getUser()).sum / 100.0 where steady_cpu results to…
Hamy
  • 20,662
  • 15
  • 74
  • 102
2
votes
3 answers

The difference between ~~ and + in javascript?

They both seem to output the same results and turn strings into numbers. Is there a difference I am not aware about? I can't seem to find any documentation regarding ~~ operator. var hey = true hey = +hey //hey = 1 var hey = true hey = ~~hey //hey…
aug
  • 11,138
  • 9
  • 72
  • 93
2
votes
1 answer

How to recognize if Flex passes NaN to ColdFusion

Flex application executes remote ColdFusion metod through RemoteObject. The remote method argument is VO. One of the numeric fields of VO is NaN. How to recognize NaN on CF side? I've tried following: this returns…
Oleg Vit'ko
  • 81
  • 1
  • 5
2
votes
2 answers

Matlab Matrix multiplication ignoring nans?

I have two matrices A and B which I want to multiply, but they contain nans. The default multiply puts nan down the whole column of the result where there was even a single nan in the data. I want to ignore them, like nansum/nanmean etc do. In…
Sanjay Manohar
  • 6,920
  • 3
  • 35
  • 58
2
votes
2 answers

Android NDK: ARMv6 + VFP devices. wrong calculations, NaN, denormal numbers, VFP11 bug

I wish to target ARMv6 with VFP Android device. I have following line in my Android.mk file to enable VFP LOCAL_CFLAGS := -marm -mfloat-abi=softfp -mfpu=vfp -Wmultichar I believe I target ARMv5 with VFP. I edited…
Max
  • 6,286
  • 5
  • 44
  • 86
2
votes
1 answer

Matlab NaN and Inf issue

So, I'm implementing the EM algorithm in Matlab, but my matrices quickly end up contaminated by NaN and Inf values. I think it might be caused by matrix inversions, but I'm not sure that's the only reason. Here is the code: function [F, Q, R, x_T,…
jerorx
  • 568
  • 6
  • 19