scientific-computing

True or false output based on a probability

戏子无情 提交于 2019-12-03 14:31:42
问题 Is there a standard function for Python which outputs True or False probabilistically based on the input of a random number from 0 to 1? example of what I mean: def decision(probability): ...code goes here... return ...True or False... the above example if given an input of, say, 0.7 will return True with a 70% probability and false with a 30% probability 回答1: import random def decision(probability): return random.random() < probability 回答2: Given a function rand that returns a number between

Modern language with the advantages of FORTRAN?

允我心安 提交于 2019-12-03 12:02:57
问题 I've been working with a lot of FORTRAN 77 lately, and though I had reservations at first, I now see some great qualities of the language. It is: Simple to learn (no object-oriented or functional-programming complications) Easy to read Blazing fast at number-crunching Those qualities are naturally attractive to non-programmer engineers and scientists who just want a way to make a computer give answers quickly. But it has a lot of limitations based on its age and some of its basic assumptions.

How to deal with underflow in scientific computing?

Deadly 提交于 2019-12-03 11:46:31
I am working on probabilistic models, and when doing inference on those models, the estimated probabilities can become very small. In order to avoid underflow, I am currently working in the log domain (I store the log of the probabilities). Multiplying probabilities is equivalent to an addition, and summing is done by using the formula: log(exp(a) + exp(b)) = log(exp(a - m) + exp(b - m)) + m where m = max(a, b) . I use some very large matrices, and I have to take the element-wise exponential of those matrices to compute matrix-vector multiplications. This step is quite expensive, and I was

Floating-point optimizations - guideline

风流意气都作罢 提交于 2019-12-03 06:02:36
问题 The majority of scientific computing problems that we need solve by implementing a particular algorithm in C/C++ demands accuracy that are much lower than double precision. For example, 1e-6 , 1e-7 accuracy covers 99% of the cases for ODE solvers or numerical integration. Even in the rare cases when we do need higher accuracy, usually the numerical method itself fail before we can dream of reaching an accuracy that is near double precision. Example: we can't expect 1e-16 accuracy from a

True or false output based on a probability

匆匆过客 提交于 2019-12-03 05:22:11
Is there a standard function for Python which outputs True or False probabilistically based on the input of a random number from 0 to 1? example of what I mean: def decision(probability): ...code goes here... return ...True or False... the above example if given an input of, say, 0.7 will return True with a 70% probability and false with a 30% probability import random def decision(probability): return random.random() < probability Blindy Given a function rand that returns a number between 0 and 1, you can define decision like this: bool decision(float probability) { return rand()<probability;

What is a good free (open source) BLAS/LAPACK library for .net (C#)? [closed]

a 夏天 提交于 2019-12-03 05:06:44
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 months ago . I have a project written in C# where I need to do various linear algebraic operations on matrices (like LU-factorization). Since the program is mainly a prototype created to confirm a theory, a C# implementation will suffice (compared to a possibly speedier C++ one), but I would still like a good BLAS or LAPACK

Logarithm Calculation with Windows 7 Calculator [closed]

会有一股神秘感。 提交于 2019-12-03 04:43:35
I would like to use the Windows Calculator in Scientific Mode in order solve a very basic Logarithm equation but, unfortunately, I couldn't do that. Here is the problem: log_5 125=? Thank you very much for your help... Well, I know it equals to "3", but, how can I use the Windows Calculator to get computed that equation for example? Shay You can calculate a logarithm in a given base by calculating two logarithms in an arbitrary base, using the following equation: log_b (x) = log_k (x) / log_k (b) As the windows calculator got a ln button, which stands for the natural logarithm (that is, log in

sigmoidal regression with scipy, numpy, python, etc

浪尽此生 提交于 2019-12-03 01:58:23
问题 I have two variables (x and y) that have a somewhat sigmoidal relationship with each other, and I need to find some sort of prediction equation that will enable me to predict the value of y, given any value of x. My prediction equation needs to show the somewhat sigmoidal relationship between the two variables. Therefore, I cannot settle for a linear regression equation that produces a line. I need to see the gradual, curvilinear change in slope that occurs at both the right and left of the

Python module for multiple variable global optimization

南笙酒味 提交于 2019-12-02 23:13:02
I have been looking for a python module that implements the common techniques of global optimization (finding the global minimum of a function in N dimensions) without success. If you heard about a simulated annealing or genetic algorithm implementation in python, please share. Justin Peel Scipy's optimize module has an anneal function that might fit your needs. Also, you should check out the PyEvolve module for doing a genetic algorithm. I'm not an expert, but have you looked at: Scipy's optimize: http://docs.scipy.org/doc/scipy/reference/optimize.html#global NLOpt: http://ab-initio.mit.edu

What is a good free (open source) BLAS/LAPACK library for .net (C#)? [closed]

我是研究僧i 提交于 2019-12-02 19:28:24
I have a project written in C# where I need to do various linear algebraic operations on matrices (like LU-factorization). Since the program is mainly a prototype created to confirm a theory, a C# implementation will suffice (compared to a possibly speedier C++ one), but I would still like a good BLAS or LAPACK library available to save me some coding. Long story short, can anybody recommend a free/open source BLAS or LAPACK library for use with .net? Best regards Egil. Update: Found Math.NET Numerics today, looks interesting, anybody have any experience with that? AMD's ACML is a free