Search Results - VBForums

Search:

Type: Posts; User: jemidiah

Page 1 of 13 1 2 3 4

Search: Search took 0.04 seconds.

  1. Replies
    8
    Views
    266

    Re: Maximum Yards Returned

    x is a value between 0 and 1 (a float), but you're making it an int. You could also make x use percentages, I suppose.
  2. Replies
    8
    Views
    266

    Re: Maximum Yards Returned

    You want what's called a "linear interpolation". If p and q are two numbers and x is a parameter between 0 and 1, you can get values in between p and q based on x using the standard formula F(x) =...
  3. Replies
    3
    Views
    381

    Re: Three guys rent a room for $30

    I agree with passel. The guys each have $-9 at the end, the bellhop has $2, and the manager has $25. -9*3 = 27 = 2+25, which makes perfect sense. The "$1 discrepancy" is just coming from confusing +...
  4. Re: [RESOLVED] Expression Evaluator - Parenthesis and Negatives

    I had a more iterative approach in mind for the lexer. That is, you run through the code character by character adding tokens to a queue as you go. It's fundamentally similar to what you're doing,...
  5. Re: Expression Evaluator - Parenthesis and Negatives

    RPN probably isn't an option here since that would force users to enter unusual syntax.

    The shunting-yard algorithm is probably what you're after here. The example and description at the link are...
  6. Re: Expression Evaluator - Parenthesis and Negatives

    I feel I should have a disclaimer at the top of this post. Namely, you probably shouldn't have to write your own parser nowadays and should instead be able to use someone else's; if you do have to...
  7. Re: [RESOLVED] reliable decimal to fraction converter

    I don't work in VB anymore, though the Python translation of that code fails on the example I gave earlier, and the VB version should be similar. Specifically, given



    def dec2frac(f):
    u =...
  8. Re: reliable decimal to fraction converter

    The trouble is your code is assuming the decimal representation infinitely repeats. For instance, for 6/5 = 1.2, you're assuming it's really 1.2222222... = 11/9. But it's not, it's 1.200000.... I...
  9. Replies
    3
    Views
    208

    Re: Logarithmic question

    I can't really understand your revised version, sorry. What I know so far: if A (the random number) is > 0.9, compute N = ceil((1+log10(1-A))/log10(0.9)), which is the smallest N such that 0.1*0.9^N...
  10. Replies
    3
    Views
    208

    Re: Logarithmic question

    Say x is the random number. If x < 0.1, you want to know when 0.1*0.9^y = x (essentially); this occurs for y = log_(0.9) (x/0.1) = (1+log10(x))/log10(0.9). For instance, if x = 0.0324, this gives...
  11. Re: reliable decimal to fraction converter

    There's a nice StackOverflow post on this topic. Roughly, you want to pick a maximum denominator size and find the numerator-denominator pair which gets closest to your number, subject to the...
  12. Replies
    8
    Views
    419

    Re: Normalized range

    Sure, there's a lot of ways to tweak it as you wish. Divide (A-B) by a magic constant, replace (A-B) with sign(A-B)*|A-B|^x for some constant x (for x=3 this reduces to just (A-B)^3; for x=2 you need...
  13. Replies
    8
    Views
    419

    Re: Normalized range

    Glad it worked out. For your revised problem, I would probably have gone for arctan, something like arctan(A-B)*2/pi + 1. It's 1 at A=B, pi/2*2/pi + 1 = 2 at A >> B, and -pi/2*2/pi + 1 = 0 at A << B.
  14. Replies
    2
    Views
    202

    Re: Looking for a small random function

    I have trouble understanding the question, eg. I don't really know what the following means: "Then will the second pair still be derived from the first pair. I'm looking for a math function on this,...
  15. Replies
    8
    Views
    419

    Re: Normalized range

    You put the negative inside the parens when it should be outside, i.e. 2 * EXP(-1*(A-B)^2). For instance, if A=1, B=0, you should get 2/e = 0.735.... Without the negative the function grows very...
  16. Replies
    8
    Views
    419

    Re: Normalized range

    Your question is a bit vague, but maybe 2exp(-(A-B)^2) is what you're after. It's 2 when A=B and is normally distributed in some sense. If you have more specific requirements, maybe those can be...
  17. Replies
    3
    Views
    424

    Re: Circular segment height?

    Yes, I understood your original post. I'm saying to find v or h requires solving a transcendental equation, which in general will have to be done numerically (or using a special function, though you...
  18. Replies
    3
    Views
    424

    Re: Circular segment height?

    Not sure why you wrote your formula in terms of v (which you didn't quite define) rather than h when you want to solve for h. Either way you have a transcendental equation, which will at best have an...
  19. Re: Get x value in relation to horizontal bar

    Yup, you're right. A little more formally, if pValue = min, you'll return 0, and if pValue = max, you'll return 1 * Me.Width, with values in between computed via linear interpolation. Roughly, the...
  20. Replies
    4
    Views
    1,970

    Re: help with a formula to find lengths

    Your reply confuses me in several ways. (1) I showed you how to find the ADP corner, but you seem to have ignored this. (2) If you could do what I did in my response, why bother asking the question...
  21. Replies
    4
    Views
    1,970

    Re: help with a formula to find lengths

    I'll assume angles that look like right angles are right angles.

    Drop a perpendicular from C to the line AD, and call the point of intersection Y. This line intersects LP at one point, say Q, and...
  22. Re: Using a mathematical identity to speed up certain calculations.

    Since the original topic is likely dead (after having been derailed twice, and having relatively little content to begin with), I'll make a few "meta" comments.

    Boy, this was a painful thread to...
  23. Re: Using a mathematical identity to speed up certain calculations.

    The timings you requested, first "GaussLCM", then naive:



    In [110]: %timeit sum_quotients5([2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43], 100000)
    10 loops, best of 3: 93.9 ms per loop
    ...
  24. Re: Using a mathematical identity to speed up certain calculations.

    Here's a little speed comparison data using the code in my previous post on my personal machine:



    : %timeit sum_quotients5([174, 192, 934, 554, 1234, 4321], 100000)
    10000 loops, best of 3: 199...
  25. Re: Using a mathematical identity to speed up certain calculations.

    Since this is "code-it-better", I thought I'd mention the Python implementation of some of these algorithms, since many of these operations are particularly straightforward in standard Python. The...
  26. Replies
    13
    Views
    2,928

    Re: [RESOLVED] Rise/Run to Angle

    That's wonderful, glad to be helpful in sparking some interest in math.
  27. Replies
    3
    Views
    388

    Re: The maximum number of divisors

    Let D(n) denote the number of divisors of n. Our first goal is to show D is "multiplicative". That is, suppose n and m are relatively prime. We'll show D(nm) = D(n)D(m).

    If d divides n and d'...
  28. Re: [C#] Finding angles based on side lengths

    Yup, that's true. Edit: though to be completely clear, you can also compute the other two angles from that information. The largest angle isn't privileged in any way.



    Yeah, it should clarify...
  29. Re: [C#] Finding angles based on side lengths

    As I understand it, you (at the moment) want to compute the angle with vertex in the middle of the red rectangle, with the black line and one of the pink lines forming the rays. In that case, I don't...
  30. Re: [RESOLVED] calculating maximum distinct char permutations

    Yup, that's what I mean. Sorry, I totally forgot I used the factorial notation without defining it. For a more thorough example of my formula, if you have R, R, R, R, G, G, G, B, Y, the answer is
    ...
  31. Re: calculating maximum distinct char permutations

    This is a classic problem with a conveniently straightforward solution. Using R, G, B, Y, R, first replace the second R with R'. There are 5! = 120 ways to permute those five characters, but really...
  32. Replies
    13
    Views
    2,928

    Re: [RESOLVED] Rise/Run to Angle

    Heh, glad some of it is clicking.
  33. Replies
    13
    Views
    2,928

    Re: [RESOLVED] Rise/Run to Angle

    Roughly speaking, you can define sin and cos to be the correct functions to use in your GetRiseRunFromAngle function, subject to the constraint that the resulting vector has length 1. That is,...
  34. Replies
    13
    Views
    2,928

    Re: [RESOLVED] Rise/Run to Angle

    A relatively minor point: it's probably best to use "New PointF(Math.Cos(radians), Math.Sin(radians))" instead of "New PointF(1, tangent)". The direction will be unaffected, but the benefits are: (1)...
  35. Replies
    13
    Views
    2,928

    Re: Rise/Run to Angle

    Converting a 2D vector to an angle is precisely the job of the atan2 function. There's a lengthy Wikipedia page about it and it's in a large number of libraries. Note there are a couple of common...
  36. Replies
    2
    Views
    547

    Re: Book about Pattern Recognition

    After some searching, I found this random Spanish-language page that seems to sell it. Failing that, I was going to suggest you contact the author directly, but I didn't find an email address or...
  37. Re: Generating rectangles around a centre point in a spiral starting from the centre

    For what it's worth, here's a brief discussion of what Lenggries called "GetX/GetY".

    Divide the plane into rectangular strips: the 0th is just (0, 0); the 1st is (0, 1), (1, 1), (1, 0), (1, -1),...
  38. Replies
    8
    Views
    777

    Re: Get X/Y coordinates

    What you're trying to do and what's not working aren't terribly clear to me, but are you sure you wanted


    Dim tilesPerHeight As Double = Math.Floor(Me.Height + ToolStrip1.Bottom / 32)

    instead...
  39. Thread: Prove this

    by jemidiah
    Replies
    2
    Views
    493

    Re: Prove this

    Multiply x<1 by x. Since 0<x, this does not reverse the inequalities, so we have 0 < x^2 < x. Take the square root of these inequalities to get 0 < sqrt(x^2) = x < sqrt(x).

    The first two sentences...
  40. Replies
    9
    Views
    1,590

    Re: Combination Picker

    I agree, the question is exactly asking for an efficient algorithm to unrank an index to produce a k-combination. I imagine there's a fair amount of literature on the problem and its generalizations,...
Results 1 to 40 of 500
Page 1 of 13 1 2 3 4



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.