numerical

Decimal points - Probability value of 0 in Language R

北战南征 提交于 2020-01-01 18:27:07
问题 How to treat p value in R ? I am expecting very low p values like: 1.00E-80 I need to -log10 -log10(1.00E-80) -log10(0) is Inf, but Inf at sense of rounding too. But is seems that after 1.00E-308, R yields 0. 1/10^308 [1] 1e-308 1/10^309 [1] 0 Is the accuracy of p-value display with lm function the same as the cutoff point, 1e-308, or it is just designed such that we need a cutoff point and I need to consider a different cutoff point - such as 1e-100 (for example) to replace 0 with <1e-100.

Round number to specified number of digits

余生颓废 提交于 2020-01-01 01:17:09
问题 Is there a simple function to round a Double or Float to a specified number of digits? I've searched here and on Hoogle (for (Fractional a) => Int -> a -> a ), but haven't found anything. 回答1: Not sure whether any standard function exists, but you can do it this way: (fromInteger $ round $ f * (10^n)) / (10.0^^n) 回答2: It depends on what you are going to do with the rounded number. If you want to use it in calculations, you should use Data.Decimal from Decimal library. If you want just to

What is the range for Arabic-Indic Digits (Hindu–Arabic) numeral utf8 from 0 to 9

馋奶兔 提交于 2019-12-30 07:51:07
问题 What is the range for Arabic-Indic Digits (Hindu–Arabic) numeral utf8 from 0 to 9 for the use in regular expressions: to use in regex. 回答1: U+06F0–U+06F9. As can be easily seen when checking a Unicode code point chart or the Character Map. 回答2: finally I found the answer for only numbers: \x{0660}-\x{0669} for numbers and letters: \x{0600}-\x{06ff} Unicode 4.0 / ISO 10646 Plane 0 thanks you all. 来源: https://stackoverflow.com/questions/14834846/what-is-the-range-for-arabic-indic-digits-hindu

Accept Numerical Values only for input using scanf

我的未来我决定 提交于 2019-12-30 07:18:20
问题 How can I make sure the user inputs numerical values only instead of alphanumeric or any other character? Also what to look for to insert error message for incorrent input? #include<stdio.h> int main() { int a, b, c; printf("Enter first number to add\n"); scanf("%d",&a); printf("Enter second number to add\n"); scanf("%d",&b); c = a + b; printf("Sum of entered numbers = %d\n",c); return 0; } 回答1: If you really want to deal with user input that could be hostile use a separate function for

Is one's complement a real-world issue, or just a historical one?

半世苍凉 提交于 2019-12-27 22:11:29
问题 Another question asked about determining odd/evenness in C, and the idiomatic (x & 1) approach was correctly flagged as broken for one's complement-based systems, which the C standard allows for. Do systems really exist in the 'real world' outside of computer museums? I've been coding since the 1970's and I'm pretty sure I've never met such a beast. Is anyone actually developing or testing code for such a system? And, if not, should we worry about such things or should we put them into Room

sorting numerically by first row

China☆狼群 提交于 2019-12-25 08:34:22
问题 I have a file with almost 900 lines in excel that I've saved as a tab deliminated .txt file. I'd like to sort the text file by the numbers given in the first column (they range between 0 and 2250). The other columns are both numbers and letters of varying length eg. myfile.txt: 0251 abcd 1234,24 bcde 2240 efgh 2345,98 ikgpppm 0001 lkjsi 879,09 ikol I've tried sort -k1 -n myfile.txt > myfile_num.txt but I just get an identical file with new name. I'd like to get: myfile_num.txt 0001 lkjsi 879

Sorting file names by numeric value

大兔子大兔子 提交于 2019-12-24 06:16:07
问题 Preamble: I hate to ask questions like this, but I'm stuck with it and just learning Perl... seems like an easy task but I don't know where to look. I have a folder with lots of xml-files that are all named ".xml". I need to process those files in their numeric order, so "9123.xml" should come before "2384747.xml". I have successfully sorted the list alphabetically with this: opendir(XMLDIR,$xmldirname); my @files = sort {$a cmp $b} readdir(XMLDIR); but this isn't what I need. I also tried my

solving a trig equation numerically with in-browser JS [closed]

空扰寡人 提交于 2019-12-23 20:44:19
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Given values for the variables s , v , and h , and given a library such as numeric.js how can I numerically solve the following equation for a within a given degree of accuracy? I'm wanting a JS algorithm for use in-browser. 回答1: Separating variables and parameters You could start by substituting b = a/h. That

gamma or log gamma function in C or C [closed]

别说谁变了你拦得住时间么 提交于 2019-12-23 13:33:20
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am seeking a C or C++ version of gamma and log gamma functions. Are there any code pieces or libraries recommended? If possible, I want to know the principle of the implementations. Thank you!!! 回答1: If you can't use C++11: The GNU GSL has all Gamma function you would ever need: http://www.gnu.org/software/gsl

Speed up a program that calculate the average of the neighbors in a huge array

我与影子孤独终老i 提交于 2019-12-23 01:30:10
问题 I have a problem with the speed of my program. I want to calculate the average of four neighbors in a huge array. Here is a part of my code. Do you have any ideas how to change the last line? Or should I use another array? for a in np.arange(100000): for x in np.arange(size): for y in np.arange(size): if unchangeableflag[x*size+y] == 0: vnew[x*size+y] = (v[(x+1)*size+y] + v[(x-1)*size+y] + v[x*size+y+1] + v[x*size+y-1]) / 4.0 回答1: You would not need the loop at all. Assuming v , vnew and