Categories
Mastering Development

Match letter to corresponding number in list in Python

I’m looking at making a program, that when the user inputs a name as an argument it matches each letter to a corresponding number stored in a list. For eg: def nameNumbers(name): alphabetList = [‘Aa’, 8.17, ‘Bb’, 1.49, ‘Cc’, 2.78, ‘Dd’, 4.25, ‘Ee’, 12.70, ‘Ff’, 2.23, ‘Gg’, 2.02, ‘Hh’, 6.09, ‘Ii’, 6.97, ‘Jj’, 0.15, ‘Kk’, […]

Categories
Mastering Development

Matplotlib | Change in plot representation when applying logarithmic scale

Given a set of points to be represented on a 3D plot (as scatter plot) I thought it would be interesting to plot the same data in 2D instead of 3D thanks to hist2d and using weights. This data has low and high values (some orders of magnitud apart) so when represented as a hist2d […]

Categories
Ask Mathematics

System of equations for two second order polynomials

I have the following data points x 2,0 5,0 8,0 10,0 y 35,0 40,0 50,0 65,0 and I want to create a system of equations for two polynomials $p_1$ and $p_2$ such that: $p_1$ goes through the data points at x=5.0 and x=8.0 $p_2$ goes through the data points at x=8.0 and x=10.0 $p_1$ and […]

Categories
Development

Generate random normal distribution with kurtosis greater than 3

A normal distribution has a kurtosis of 3. With an increase in outliers in the distribution, the tails become “fat” and the kurtosis increases beyond 3. How do I generate a random distribution between two numbers with kurtosis greater than 3 (preferably around 5-7)? Imports import numpy as np import scipy.stats import kurtosis Random Uniform […]

Categories
Development

SQL Server Spatial Issue

I am trying to create a curved line between two points so that I can use it with the mapping product MapBox and use it in the co-ordinates section. I am having some issues with it and am unclear about how to control the curve The Microsoft documentation talks about curving the line https://docs.microsoft.com/en-us/sql/t-sql/spatial-geometry/stcurvetoline-geometry-data-type?view=sql-server-ver15 I […]

Categories
Development

Fast alternative for np.median.reduceat

Relating to this answer, is there a fast way to compute medians over an array that has groups with an unequal number of elements? E.g.: data = [1.00, 1.05, 1.30, 1.20, 1.06, 1.54, 1.33, 1.87, 1.67, … ] index = [0, 0, 1, 1, 1, 1, 2, 3, 3, … ] And then I want […]

Categories
Development MATLAB

why the results of fortran mkl-fftw3 and matlab are not aligned?

I just want to convert my code from matlab to fortran. So I used the mkl-fftw3 library to complete the FFT computation. But during my test, the position of mkl-fftw3 results does not align with matlab results, it might seems like it’s the reverse of matlab results. Is there anyway to transform the fortran results […]

Categories
Development MVC

Iterate cartesian product (cross product) of sorted lists of positive numbers in order of decreasing product of entries (MVCE of a stub included)

Suppose I have several sorted lists of positive numbers, like so for example: double[] a1 = new double[]{0.70, 0.20, 0.10}; double[] a2 = new double[]{0.80, 0.10, 0.05, 0.05}; double[] a3 = new double[]{0.60, 0.15, 0.14, 0.10, 0.01}; I want to iterate Cartesian product of these arrays in the order of decreasing product of entries, like […]

Categories
Development

TensorFlow: Random Normal Value from Distribution with Parameters=Tensor

I want to create an output where I take a random value from a normal distribution, but have the parameters of the normal distribution be based on a Tensor Variable. For example: new = tf.map_fn(lambda x: tf.random.normal([1], x, 1.0), new) new = tf.map_fn(lambda x: np.random.normal(0, x, 0.1)[0], new) Where “new” is of type tf.Variable that […]

Categories
Development

PYMC3 Multinomial Choice Modelling

Update Using pm.Multinomial with n=1 and shape=11 instead of pm.Categorical works, however I also need to specify init=’adapt_diag’ when sampling or it will result in bad energy. Any ideas on this? I still don’t understand why Categorical does not work. Original Post I am trying to make Bayesian inference on simulated data, i.e. I know […]