math

Can I force two components in a three-way linear regression to be positive?

Hello, I'm sorry if I'm not using the correct mathemathical terms, but I hope you'll understand what I'm trying to accomplish. My problem: I'm using linear regression (currently least squares method) on the values from two vectors x and y against the result z. This is to be done in matlab, and I'm using the \-operator to perform the reg...

User-friendly math textbooks?

As usual I'm working my way through a couple of programming books (Intermediate Perl and just started on The Little Schemer) and what struck me is that they really seem to put some thought into how they present the material. They're easy to read, and they seem to assume that you're working through them all by yourself (without an instruc...

Learning Applied Statistics with a focus on R

I know MIT and Stanford have placed many videos online of their courses. Does anybody know of a course (with videos available online) of Applied Statistics? I've been playing with R and the tool (from a technical side) is pretty straightforward. However, I'm quite clueless when it comes to the statistical side (regressions, recursive p...

How do you calculate the Angle of Incidence?

I'm working on a raytracer for a large side project, with the goal being to produce realistic renders without worrying about CPU time. Basically pre-rendering, so I'm going for accuracy over speed. I'm having some trouble wrapping my head around some of the more advanced math going on in the lighting aspects of things. Basically, I have...

Question on moduli

Hi, I want to find all the numbers divisble by all the numbers between 1 and 5. how do I write the program so that if the remainder of 'start' divided by all the numbers that x goes through is equal to 0 that it will print start. Is there any syntax that will calculate what I'm looking for. thanks. import math def main(): one = 1 ...

how to simplify this code (math stuff)

so it's ugly, but it work, so here it is squareExp2 can be 9 or 16 Square can be 3 or 4 length of the gridbox and gridbox1 array can be 0 to 80 or 0 to 255 (you see the pattern now) this code is ran only one time, at runtime For j = 0 To squareExp2 - 1 For i = 0 To squareExp2 - 1 box = (j * squareExp2) + i ...

Best algorithm for evaluating a mathematical expression?

What's the best algorithm for evaluating a mathematical expression? I'd like to be able to optimize this a little in the sense that I may have one formula with various variables, which I may need to evaluate hundreds of times using different variables. So basically if I can initially parse the formula so that it is optimized in some way,...

How to get started on Information Extraction?

Could you recommend a training path to start and become very good in Information Extraction. I started reading about it to do one of my hobby project and soon realized that I would have to be good at math (Algebra, Stats, Prob). I have read some of the introductory books on different math topics (and its so much fun). Looking for some gu...

Looking for actively maintained matrix math library for php

Does anyone know where I might find a PHP matrix math library which is still actively maintained? I need to be able to do the basic matrix operations like reduce, transpose (including non-square matrices), invert, determinant, etc. This question was asked in the past, then closed with no answers. Now I need an answer to the same questi...

Help me with Rigid Body Physics/Transformations

I want to instance a slider constraint, that allows a body to slide between point A and point B. To instance the constraint, I assign the two bodies to constrain, in this case, one dynamic body constrained to the static world, think sliding door. The third and fourth parameters are transformations, reference Frame A and reference Frame B...

Pythagorean triplets

Hi, this is a program I wrote to calculate pythagorean triplets. When I run the program it prints each set of triplets twice beacuse of the if statement. is there any way I can tell the program to only print a new set of triplets once. thanks. import math def main(): for x in range (1, 1000): for y in range (1, 1000): ...

How do I solve a set of constraints in Perl?

I have the following set of constraints in Perl (just a sample set of constraints, not the ones I really need): $a < $b $b > $c $a is odd => $a in [10..18] $a > 0 $c < 30 And I need to find a list ($a, $b, $c) that meet the constraints. My naive solution is sub check_constraint { my ($a, $b, $c) = @_; if !($a < $b) {return 0...

Math help - Can't rotate something (knowing Java would be a plus)

Okay I'm trying to rotate a Java Polygon based on it's original position of angle 0. x, and y end up being converted to an int at the end of me using them, so I could understand not seeing some change, but when the difference in angles is big like 0 to 180 I think I should see something. I've been at this for a little while and can't t...

Curve Fitting

Given two points say (1,2,3) and (4,7,8). The endpoint tangents at these points are also given as inputs say pi/4 and -pi/2 respectively. How to fit a helix of arc length 2 between these points? How to implement this in Matlab? ...

As a programmer how would you explain imaginary numbers?

As a programmer I think it is my job to be good at math but I am having trouble getting my head round imaginary numbers. I have tried google and wikipedia with no luck so I am hoping a programmer can explain in to me, give me an example of a number squared that is <= 0, some example usage etc... ...

Good programming/math literature

I recently read The Numerati by Stephen Baker. It is an AMAZING book which really opens your eyes to all the possibilities of new emerging technology. I was wondering if anyone (preferably who has read The Numerati) could suggest a good read? I'm not looking for anything "code related". Thanks! ...

Rotating a glViewport ?

In a "multitouch" environement, any application showed on a surface can be rotated/scaled to the direction of an user. Actual solution is to drawing the application on a FBO, and draw a rotated/scaled rectangle with the texture on it. I don't think it's good for performance, and all graphics cards don't provide FBO. The idea is to clip ...

How trustworthy is javascript's random implementation in various browsers?

I would like to do some experimenting with javascript and encryption and I got curious as to how unpredictable the implementation of the random function is. Has anyone done any hard tests? Clearly browsers have the ability to generate strong randomness (for ssl). The questions is do they give javascript access to the same strength. ...

Get bools out of byte and the other way

Simple question: How do i tell which bits in the byte are set to 0 and which are set to 1 for example: //That code would obviously wont work, but how do i make something similar that would work? byte myByte = 0X32; foreach(bool bit in myByte) { Console.WriteLine(bit); } //Part 2 revert bool[] bits = new bool[8]; bits[0] = 0 bits[...

WPF: Getting new coordinates after a Rotation

With reference to this programming game I am currently building. To translate a Canvas in WPF, I am using two Forms: TranslateTransform (to move it), and RotateTransform (to rotate it) [children of the same TransformationGroup] I can easily get the top left x,y coordinates of a canvas when its not rotated (or rotated at 90deg, since ...