math

What is a simple formula for a non-iterative random number sequence?

风格不统一 提交于 2021-02-10 23:41:14
问题 I would like to have a function f(x) that gives good pseudo-random numbers in uniform distribution according to value x. I am aware of linear congruential generators, however these work in iterations, i.e. I provide the initial seed and then I get a sequence of random values one by one. This is not what I want, because if a want to get let's say 200000th number in the sequence, I have to compute numbers 1 ... 199999. I need a function that is given by one simple formula that uses basic

How to extract the function model (polynomials) from scipy.interpolate.splprep()?

不问归期 提交于 2021-02-10 22:10:57
问题 I now have some discrete points, and I interpolated it using the scipy.interpolate.splprep () function (B-spline interpolation) to get a satisfactory smooth curve. Here's the code (draw on the answer to another question) and the result I got. import numpy as np from scipy import interpolate from matplotlib import pyplot as plt # x and y are points sampled randomly x = sampledx y = sampledy # append the starting x,y coordinates x = np.r_[x, x[0]] y = np.r_[y, y[0]] # fit splines to x=f(u) and

How to set panning limits on WPF Canvas based on zoom level?

时间秒杀一切 提交于 2021-02-10 20:48:14
问题 I'm trying to set zooming and panning limits on a control I found here: https://wpfextensions.codeplex.com I managed to set zooming limits, but now I'm having trouble setting the panning limits so that you can't pan the object inside the canvas, outside the view. I succeeded in setting the limits, but only when the zoom level is 1 ( Zoom == 1 , so no zoom), but the moment you increase the zoom (by rotating the mouse wheel) things start to go wrong : the limits are set, but they are not set

How to set panning limits on WPF Canvas based on zoom level?

落花浮王杯 提交于 2021-02-10 20:47:19
问题 I'm trying to set zooming and panning limits on a control I found here: https://wpfextensions.codeplex.com I managed to set zooming limits, but now I'm having trouble setting the panning limits so that you can't pan the object inside the canvas, outside the view. I succeeded in setting the limits, but only when the zoom level is 1 ( Zoom == 1 , so no zoom), but the moment you increase the zoom (by rotating the mouse wheel) things start to go wrong : the limits are set, but they are not set

How to calculate ray in real-world coordinate system from image using projection matrix?

你说的曾经没有我的故事 提交于 2021-02-10 20:38:56
问题 Given n images and a projection matrix for each image, how can i calculate the ray (line) emitted by each pixel of the images, which is intersecting one of the three planes of the real-world coordinate system? The object captured by the camera is at the same position, just the camera's position is different for each image. That's why there is a separate projection matrix for each image. As far as my research suggests, this is the inverse of the 3D to 2D projection. Since information is lost

How to calculate ray in real-world coordinate system from image using projection matrix?

≡放荡痞女 提交于 2021-02-10 20:35:36
问题 Given n images and a projection matrix for each image, how can i calculate the ray (line) emitted by each pixel of the images, which is intersecting one of the three planes of the real-world coordinate system? The object captured by the camera is at the same position, just the camera's position is different for each image. That's why there is a separate projection matrix for each image. As far as my research suggests, this is the inverse of the 3D to 2D projection. Since information is lost

Math operations with long long in c

Deadly 提交于 2021-02-10 20:15:08
问题 Given long long x , long long y , and int z , how can trunc(( x + y + z )/3) be calculated using fully defined operations in C but excluding unsigned long long and wider arithmetic? (trunc( x ) is “rounding toward zero”: It is x if x is an integer and otherwise is the next integer toward zero.) 回答1: You can calculate the average of two integers x and y without the risk of overflow as follows (pseudocode): int average = (x and y have the same sign) ? x + (y - x) / 2 : (x + y) / 2; This is not

Is there a Python package that can trace a curve with a Gaussian lineshape over several x and y values?

人盡茶涼 提交于 2021-02-10 18:29:21
问题 My apologies for my ignorance in advance; I've only been learning Python for about two months. Every example question that I've seen on Stack Overflow seems to discuss a single distribution over a series of data, but not one distribution per data point with band broadening. I have some (essentially) infinitely-thin bars at value x with height y that I need to run a line over so that it looks like the following photo: The bars are the obtained from the the table of data on the far right. The

Find the nXn submatrix with the highest number of 1's

谁说胖子不能爱 提交于 2021-02-10 14:53:22
问题 I tried to solve this question but without success: Given 3n X 3n boolean matrix, find the nXn submatrix with the highest number of 1's in O(n^2). I had an idea but it was O(n^3). The idea: count the 1's in the matrix begin with (0,0) and move to the right and check only the new col that should be added VS the col that should be deleted. And the same idea for down. Each submatrix calculation is O(n^2) and passing all the matrix is O(n) so it's too much. I don't see a way how to pass across

Logical operators in if-else in R

霸气de小男生 提交于 2021-02-10 06:48:39
问题 I have the following table (5 columns and 3 rows) called mat : AC CA RES 1 0 2 2 1 3 0 0 0 1 The operation being performed is mat[1]/mat[1]+mat[2] I am testing for the following : 1) If both columns of a row are zero, the result should be NA. 2) If only one column of a row is zero and the other has a non-zero number, proceed with calculation. (Even if the numerator is 0, that's okay) I am currently using this if-else structure within a for-loop going row-wise: if(mat[b,1]>=0|mat[b,2]>=0){mat