approximation

Why is the data stored in a Float datatype considered to be an approximate value?

风格不统一 提交于 2019-12-12 18:09:35
问题 I've never understood why a float datatype is considered an approximation while a decimal datatype is considered exact. I'm looking for a good explanation, thanks. 回答1: well, you're right - it's misleading to make such a blanket statement. to understand completely you need to grasp two things. first, decimal is intended for storing (exactly) decimal values with a fixed number of decimal places. typically, money (where the decimals are cents, for example). that's a very specific use case. it's

Local Sensitive Hashing using a arbitray non euclidean metric

风格不统一 提交于 2019-12-11 11:59:13
问题 I have a very specific question. I work on a project, were I need to find nearest neighbours (k and near). As I dont need the excat ones and want to be able to extend to high dimensions, I focused on LSH. My data has a distance that is a metric, but non euclidean. I found many ways for vector space with euclidean metric (e.g. the p stable distribution), binary coding(via projections) or string based. What I am searching are papers that present a LSH template for an arbitrary metric. Does

finding absolute error of approximated function - matlab

和自甴很熟 提交于 2019-12-11 09:06:21
问题 During an experiment i registered several points. Thereafter I approximated them with 9th order polynomial. I need to find the absolute error of the measurements and the approximated function on y axis. Any idea? *edit: y = [0.006332 0.04056 0.11813 0.1776723 0.23840 0.29827 0.358396... 0.418149 0.4786 0.478154 0.538114 0.53862 0.598954 0.659804... 0.720267 0.781026 0.8412 0.901548 0.962022 1.022567 1.083291... 1.143653 1.20449 1.14398 1.02273 0.962285 0.90203 0.841474... 0.780881 0.720346 0

C++ Pi Approximation using Leibniz Formula

安稳与你 提交于 2019-12-11 06:58:08
问题 I'm a beginner at C++ and coding itself, so please forgive any vocabulary mishaps. I couldn't find this specific question but similar ones on the internet, but I'm still having a hard time getting an outcome I need. So I'm using the Leibniz Formula to approximate pi which is: pi = 4 · [ 1 – 1/3 + 1/5 – 1/7 + 1/9 … + (–1 ^ n)/(2n + 1) ]. I've written a compilable and runnable program , but the main part of the code that's troubling me is: if (terms > 0){ double partial = 0; for (i = 0; i <

What is the ε (epsilon) parameter in Locality Sensitive Hashing (LSH)?

好久不见. 提交于 2019-12-11 01:37:10
问题 I've read the original paper about Locality Sensitive Hashing. The complexity is in function of the parameter ε, but I don't understand what it is. Can you explain its meaning please? 回答1: ε is the approximation parameter . LSH (as FLANN & kd-GeRaF) is designed for high dimensional data. In that space, k-NN doesn't work well, in fact it is almost as slow as brute force, because of the curse of dimensionality. For that reason, we focus on solving the aproximate k-NN. Check Definition 1 from

PHP wrong approximation with printf

為{幸葍}努か 提交于 2019-12-10 22:45:58
问题 I am fully aware of the floating point representation in binary format, so I know there are mathematical "impossibilities" when trying to perfectly represent a floating point number in any programming language. However, I would expect a programming language to follow some well known and well established rules when dealing with approximation. Having said so, I read (here on stackoverflow too) that printf in PHP is probably the best way to "correctly truncate/approximate" a number, and - again

Efficiently calculate top-k elements in spark

戏子无情 提交于 2019-12-10 10:14:15
问题 I have a dataframe similarly to: +---+-----+-----+ |key|thing|value| +---+-----+-----+ | u1| foo| 1| | u1| foo| 2| | u1| bar| 10| | u2| foo| 10| | u2| foo| 2| | u2| bar| 10| +---+-----+-----+ And want to get a result of: +---+-----+---------+----+ |key|thing|sum_value|rank| +---+-----+---------+----+ | u1| bar| 10| 1| | u1| foo| 3| 2| | u2| foo| 12| 1| | u2| bar| 10| 2| +---+-----+---------+----+ Currently, there is code similarly to: val df = Seq(("u1", "foo", 1), ("u1", "foo", 2), ("u1",

How to measure complexity of a string?

两盒软妹~` 提交于 2019-12-10 02:33:17
问题 I have a few long strings (~ 1.000.000 chars). Each string only contains symbols from the defined alphabet, for example A = {1,2,3} Sample strings string S1 = "1111111111 ..."; //[meta complexity] = 0 string S2 = "1111222333 ..."; //[meta complexity] = 10 string S3 = "1213323133 ..."; //[meta complexity] = 100 Q What kind of measures can I use to quantify the complexity of these strings? I can see that S1 is less complex than S3, but how can I do that programmatically from .NET? Any algorithm

Power of 2 approximation in fixed point

六月ゝ 毕业季﹏ 提交于 2019-12-09 23:36:16
问题 Currently, I am using a small lookup table and linear interpolation which is quite fast and also accurate enough (max error is less than 0.001). However I was wondering if there is an approximation which is even faster. Since the integer part of the exponent can be extracted and calculated by bitshifts, the approximation just needs to work in the range [-1,1] I have tried to find a chebyshev polynomial, but could not achieve a good accuracy for polynomials of low order. I could live with a

Round Up a double to int

狂风中的少年 提交于 2019-12-09 03:30:59
问题 I have a number ("double") from int/int (such as 10/3). What's the best way to Approximation by Excess and convert it to int on C#? 回答1: Are you asking about System.Math.Ceiling? Math.Ceiling(0.2) == 1 Math.Ceiling(0.8) == 1 Math.Ceiling(2.6) == 3 Math.Ceiling(-1.4) == -1 回答2: int scaled = (int)Math.Ceiling( (double) 10 / 3 ) ; 回答3: By "Approximation by Excess", I assume you're trying to "round up" the number of type double. So, @Doug McClean's "ceiling" method works just fine. Here is a note