Is there a practical algorithm that gives "multiplication chains"
To clarify, the goal is to produce a multiplication change of an arbitrary and exact length
Multiplication chains of length 1 are trivial.
A "multiplication chain" would be defined as 2 numbers, {start} and {multiplier}, used in code:
Given a pointer to array of size ...
I'm looking for a an R package which can be used to train a Dirichlet prior from counts data. I'm asking for a colleague who's using R, and don't use it myself, so I'm not too sure how to look for packages. It's a bit hard to search for, because "R" is such a nonspecific search string. There doesn't seem to be anything on CRAN, but ar...
Anyone want to share some nice code that gives the position of the sun (elevation and azimuth) given latitude and longitude and time of day ?
And date, of course.
...
What is the most efficient way to cacluate the closest power of a 2 or 10 to another number? e.g.
3.5 would return 4 for power of 2 and 1 for power of 10
123 would return 128 for power of 2 and 100 for power of 10
0.24 would return 0.25 for power of 2 and 0.1 for power of 10
I'm just looking for the algorithm and don't mind the langu...
I am doing 2^1000 and am getting this:
1.07151e+301
Is there any way to actually turn this into a proper number without the e+301 or at least can anyone show me where I can see how to turn this in to a real number, by some way working with the e+301 part
Thanks
...
I have seen 3d surface plots of data before but i do not know what software i could use to make it.
I have 3 series of data (X, Y, Z) basically i want each of the rows on the table to be a point in 3d space, all joined as a mesh. The data is currently csv, but i can change the format, as it is data i generated myself.
Can anyone help
...
For example, in http://homepages.cwi.nl/~paulv/papers/algorithmicstatistics.pdf at the bottom of page 5 and top of page 6, he uses a plus/equal symbol and a similar plus/lessthan symbol. I can't figure out how to make that symbol, and I'd like to quote him.
Any help?
...
How to, in C# round up any value to 10 interval? For example, if I have 11, I want it to return 10, if I have 136, then I want it to return 140.
I can easily do it by hand
return ((int)( number/10))*10
But I am looking for an builtin algorithm to do this job, something like Math.Round(). The reason why I won't want to do by hand is ...
Hi,
I studied computer engineering 10 years ago and i know all the basics of object programming.
I didn't write any code for 5 years but actually I'm thinking to go back to this business for a specific need :
Now I'm a mathematic teacher in a secondary school and i want to develop a little software that help students to organize their g...
I need a function count_permutations() that returns the number of permutations of a given range. Assuming that the range is allowed to be modified, and starts at the first permutation, I could naively implement this as repeated calls to next_permutation() as below:
template<class Ret, class Iter>
Ret count_permutations(Iter first, Iter ...
I studied computer engineering 10 years ago and i know all the basics of object programming. I didn't write any code for 5 years but actually I'm thinking to go back to this business for a specific need :
Now I'm a mathematic teacher in a secondary school and i want to develop a little free software that help students to organize their ...
It's been a few years since my computational geometry class in college, and I unfortunately sold my textbook (Computational Geometry in C), so now that I am writing a 2D video game, I am looking for books to give me a hand. What books are recommended that cover the geometry, math, and physics of 2D video game development?
...
I have a game in which you can score from -40 to +40 on each match.
Users are allowed to play any number of matches.
I want to calculate a total score that implicitly takes into account the number of matches played.
Calculating only the average is not fair.
For example, if Peter plays four games and gets 40 points on each match, he wil...
For large n (see below for how to determine what's large enough), it's safe to treat, by the central limit theorem, the distribution of the sample mean as normal (gaussian) but I'd like a procedure that gives a confidence interval for any n. The way to do that is to use a Student T distribution with n-1 degrees of freedom.
So the quest...
Are there any known hash algorithms which input a vector of int's and output a single int that work similarly to an inner product?
In other words, I am thinking about a hash algorithm that might look like this in C++:
// For simplicity, I'm not worrying about overflow, and assuming |v| < 7.
int HashVector(const vector<int>& v) {
cons...
I have the following equation
1 - ((.5 * 0.83333333333333) ^ 2 + (.5 * 0.83333333333333) ^ 2 + (.5 * (1 - 0.83333333333333)) ^ 2 + (.5 * (1 - 0.83333333333333)) ^ 2)
In Php5, this results in an answer of 1 as opposed to .63 (on two machines, OSx and Centos). Should I be exclusively using the bc math functions of Php to do equations l...
Can any one recommend a good JavaScript library to solve floating point problems in JavaScript?
...
I have been trying to learn more about lambda expressions lately, and thought of a interesting exercise...
is there a way to simplify a c++ integration function like this:
// Integral Function
double integrate(double a, double b, double (*f)(double))
{
double sum = 0.0;
// Evaluate integral{a,b} f(x) dx
for(int n = 0 ; n <...
I'm working with large numbers that I can't have rounded off. Using Lua's standard math library, there seem to be no convenient way to preserve precision past some internal limit. I also see there are several libraries that can be loaded to work with big numbers:
http://oss.digirati.com.br/luabignum/
http://www.tc.umn.edu/~ringx004/m...
How to convert last 3 digits of number into 0
example 3444678 to 3444000
I can do like
(int)(3444678/1000) * 1000= 3444000
But division and multiplication could be costly...
Any other solution????
...