i’m generating Random values with range of 5.0 – 9.0, are the numbers generated still uniformly distributed theoretically ?? and how to implement the histogram, i mean what values we need to implement the histogram ?? i’m zero on math .., pls help me Answer You are on the righ path- scaling the numbers linearly is correct. To test your
Tag: math
Rounding Up To The Nearest Hundred
I came to a part in my java program where I need to round up to the nearest hundred and thought that there was probably some way to do it but I guess not. So I searched the net for examples or any answers and I’ve yet to find any since all examples appear to be to the nearest hundred.
Logarithm Algorithm
I need to evaluate a logarithm of any base, it does not matter, to some precision. Is there an algorithm for this? I program in Java, so I’m fine with Java code. How to find a binary logarithm very fast? (O(1) at best) might be able to answer my question, but I don’t understand it. Can it be clarified? Answer
How to test if a double is an integer
Is it possible to do this? I know the code probably doesn’t go anything like that, but how does it go? Answer This checks if the rounded-down value of the double is the same as the double. Your variable could have an int or double value and Math.floor(variable) always has an int value, so if your variable is equal to
How do you get absolute values and square roots
How do you get a square root and an absolute value in Java? Here is what I have: But is there an easier way to get the absolute value in Java? Answer Use the static methods in the Math class for both – there are no operators for this in the language: (Likewise there’s no operator for raising a value
Is there a commonly used rational numbers library in Java?
I’m looking for a Java library which represents fractions (rational numbers). For example, if I want to store the fraction 1/3 then it will not be saved as 0.33333 which will lose its accuracy. Here …
midpoint between two latitude and longitude
I am trying to convert the code snippet given in this http://www.movable-type.co.uk/scripts/latlong.html into java. But I am not getting same result as that of site. Here is my code to find the midpoint between two points where their latitudes and longitudes are given I am not sure whethe dLon is correct or not. So please help me guys to figure
Mid point of two point where latitude and longitude given
I am trying to find the midpoint of two points where latitude and longitude of those points are given. Using Haversine formula I can able to find the distance between between those points. I guess, I can also able find the midpoint by dividing the distance by 2. After that how can find the latitude and longitude of that midpoint.
Unit testing mathematical code
I am writing a small utility for calculating a complicated mathematical formula (using commons-math library for integration and root finding). I was trying to write it in the same way as a normal …
Circle approximations using Bezier curves
I have 2 questions about bezier curves, and using them to approximate portions of circles. Given the unit circle arc (1,0)->(cos(a),sin(a)) where 0 < a < pi/2, will it result in a good approximation of this arc to find the bezier curve’s control points p1, p2 by solving the equations imposed by the requirements B(1/3) = (cos(a/3), sin(a/3)) and B(2/3)