Questions tagged [approximate]

Finding or verifying that a value is 'close enough' to some target value.

The tag is used both for questions relating to determining an approximate value (i.e. calculating a value to withing a certain tolerance) and the act of verifying or determining the 'closeness' of a value to a another (e.g. approximate string matching).

See also: .

99 questions
54
votes
2 answers

How to perform approximate structural pattern matching for floats and complex

I've read about and understand floating point round-off issues such as: >>> sum([0.1] * 10) == 1.0 False >>> 1.1 + 2.2 == 3.3 False >>> sin(radians(45)) == sqrt(2) / 2 False I also know how to work around these issues with math.isclose() and…
11
votes
4 answers

Approximate string matching

I know this question have been asked a lot of time. I want a suggestion on which algorithm is suitable for approximate string matching. The application is specifically for company name matching only and nothing else. The biggest challenge is…
Max
  • 113
  • 1
  • 1
  • 4
11
votes
2 answers

How to use n-grams approximate matching with Solr?

We have a database of movies and series, and as the data comes from many sources of varying reliability, we'd like to be able to do fuzzy string matching on the titles of episodes. We are using Solr for search in our application, but the default…
Ryszard Szopa
  • 5,431
  • 8
  • 33
  • 43
9
votes
1 answer

What is the difference between MiniTest's assert_in_delta and assert_in_epsilon methods?

Here is documentation for assert_in_delta: assert_in_delta(exp, act, delta = 0.001, msg = nil) public For comparing Floats. Fails unless exp and act are within delta of each other. assert_in_delta Math::PI, (22.0 / 7.0), 0.01 And here is the…
Tom Lord
  • 27,404
  • 4
  • 50
  • 77
6
votes
5 answers

How do I find the closest array element to an arbitrary (non-member) number?

Seemingly similar questions: "Finding closest number in an array" (in Java) and "find nearest match to array of doubles" (actually a geography problem). I have a (sorted) array of doubles. Given an arbitrary number (which may or may not be an exact…
Tom Wright
  • 11,278
  • 15
  • 74
  • 148
6
votes
3 answers

OpenCV - DrawContour at an offset

I'm using OpenCV for image processing. I am looking for a human body, wich I want to isolate (segment). Currently, I am able to find the contour of the body, and approximate the contour with a Polygon. Next, I would like to use that contour in…
Entreco
  • 12,738
  • 8
  • 75
  • 95
5
votes
1 answer

Efficient scheduling jobs with declining profits on multiple machines

Problem: Consider the scheduling problem of n jobs on M machines where each job i have a processing time pi and gives a profit gi(t) if completed by time t. All the jobs are released at time 0. All gi(t) are non-increasing functions. For simplicity,…
v78
  • 2,803
  • 21
  • 44
5
votes
2 answers

Excel Approximate Text Match

I'm trying to check how many strings in column A approximately match a string in column B. Example: If I have the string "angry_birds_iph_app" in column B, and "angry_birds_iph_app" and "angry_birds_adrd_app" appear somewhere in column A, I would…
Tom Wall
  • 125
  • 1
  • 2
  • 9
4
votes
1 answer

Searching through HashMap coordinates

I am working on a GUI application. The GUI consists of a map with cities. Each city has an X and a Y coordinate. The cities are stored in a HashMap like the following: cities.put(new Coordinates(X, Y), "City Name"); Where X and Y are just some…
Sameer
  • 281
  • 1
  • 2
  • 8
4
votes
4 answers

Approximate equality of unordered set of complex floats

I want to do nose testing of numpy arrays of complex floats that are unordered. So for instance, if a = [1+1j, 1-1j, 2+2j, 2-2j, 2+2j, 2-2j] and b = [2+2j, 2-2j, 1+1j, 1.000000000000001-1j, 2+2j, 2-2j] the assert should succeed, as they have…
endolith
  • 25,479
  • 34
  • 128
  • 192
4
votes
3 answers

In Python, how can I check if 2 numbers in a list are within a certain percentage of each other?

I have a large list of numbers, and I want to see if any of them are approximately equal. If 2 numbers are "approximately equal" (for my purposes), both of them fall within 10% of each other (see the following 2 examples.) Then I want to sort them…
leon
  • 65
  • 1
  • 8
4
votes
3 answers

comparing doubles with adaptive approximately equal

I am attempting to make an adaptive 'about equal' method (written in C# but the question is general) accepting two doubles and returning a boolean if they are 'about equal' or not. By adaptive, I mean that: 1.234 and 1.235 ==> TRUE BUT 1.234567 and…
chessofnerd
  • 1,219
  • 1
  • 20
  • 40
3
votes
1 answer

Using an "approximate" STL map

I would like to create an STL map to find whether an item is close enough to another item in 3 dimensional space. So far, my "less-than-functor" has worked quite well, pasted to the following link. Now this problem isn't quite the "nearest neighbor"…
macetw
  • 1,640
  • 1
  • 17
  • 26
3
votes
2 answers

Finding a vector that is approximately equally distant from all vectors in a set

I have a set of 3 million vectors (300 dimensions each), and I'm looking for a new point in this 300 dim space that is approximately equally distant from all the other points(vectors) What I could do is initialize a random vector v, and run an…
3
votes
1 answer

Pi approximation in C - why am I getting a result of 0 for the approximation?

I'm trying to write a Quasi- Monte Carlo Approximation of pi in C. I am not well versed in it yet and am trying to translate my python based skills, so I may be simply overlooking something. I keep getting 0 as a result and I can't figure out why. …
Tristen
  • 57
  • 1
  • 1
  • 7
1
2 3 4 5 6 7