Categories

## Generate probability distribution or smoothing plot from points containing probabilities

I have points which include the probability on the y-axis and values on the x-axis, like: p1 = [[0.0, 0.0001430560406790707], [10.0, 6.2797052001508247e-13], [15.0, 4.8114669550502021e-06], [20.0, 0.0007443231772534647], [25.0, 0.00061070912573869406], [30.0, 0.48116582167944905], [35.0, 0.24698643991977953], [40.0, 0.016407283121225951], [45.0, 0.2557158314329116], [50.0, 1.1252231121357235e-05], [55.0, 0.064666668633158647], [60.0, 1.7631447655837744e-17], [65.0, 1.1294722466816786e-14], [70.0, 2.9419020411134367e-16], [75.0, 3.0887653014525822e-17], [80.0, 4.4973693062706866e-17], [85.0, 9.0975358174005147e-15], [90.0, 1.0758266454985257e-10], [95.0, […]

Categories

## Rotation of an object in Mayavi (python)

A couple of questions: I put together multiple parts of the available online scripts, mainly matplotlib and mayavi websites, to create the below scripts. How can I rotate one of the shperes relative to the other by using Euler angles or the quaternion of each spheres? (I do not mean rotation of the viewpoint, just […]

Categories

## Separator between strings from JSON

I am trying to save text file with string values from JSON array (Pandas library), but I am strugling to separate them with comma sign. What I want achieve is this: 0, 0, 0 1, 0, 5 2, 0, 10 3, 0, 15 4, 5, 0 5, 10, 0 6, 15, 0 7, 15, 5 […]

Categories

## How to apply linear regression with fixed x intercept in python?

I’ve found quite a few examples of fitting a linear regression with zero intercept. However, I would like to fit a linear regression with a fixed x-intercept. In other words, the regression will start at a specific x. I have the following code for plotting. import numpy as np import matplotlib.pyplot as plt xs = […]

Categories

## How do I fix an Integer Value Error in Pyomo MindtPy solver

I am trying to go through the MindtPy example problem (https://pyomo.readthedocs.io/en/stable/contributed_packages/mindtpy.html) and it does not work. Here is my code: from pyomo.environ import * #Create a simple model model = ConcreteModel() model.x = Var(bounds=(1.0,10.0),initialize=5.0) model.y = Var(within=Binary) model.c1 = Constraint(expr=(model.x-3.0)**2 <= 50.0*(1-model.y)) model.c2 = Constraint(expr=model.x*log(model.x)+5.0 <= 50.0*(model.y)) model.objective = Objective(expr=model.x, sense=minimize) #Solve the model using […]

Categories

## Group by / Drop duplicates / Sum holding

I am using JupyterLab to print some data in a spreadsheet in a specific way. I have two different files: 1) 2) For every original_id == id I want to group by country and list the brands and summing and listing the holding for each brand. The result I got with my code is this: […]

Categories

## Pyqtgraph candlestick

I used this code: https://github.com/pyqtgraph/pyqtgraph/blob/develop/examples/customGraphicsItem.py I replaced data with a file.csv The lines are written this way: 2019-11-07 21:40:00+00:00,9190.5,36024221.0,9200.0,3922.7451237799987,1067.0,9169.0,9180.5,XBTUSD,6202,392274512378,36024221,9183.5798 timestamp,close,foreignNotional,high,homeNotional,lastSize,low,open,symbol,trades,turnover,volume,vwap I would like to know how to get the date on the x-axis. For the moment I use: self.x = [i for i in range (len(self.open))] and w = 1/3 Exemple : import sys from […]

Categories

## How could I add and update data in random order in a two-dimension matrix in Java

for example the input is: (row, column, weight), such as (0,2,10.0) ,(1,2,3.0), (2,1,11.3), (1,2, 15.0) the result should be: 0 1 2 0 . . 10.0 1 . . 15.0 2 . 11.3 . (the data would be both inserted and updated) I have noticed that it could not be done by simply using add(index […]

Categories

## Saving array as Geotiff using rasterio

I have the following numpy array: supervised.shape (1270, 1847) I am trying to use the following code to save it to GeoTIFF using rasterio: with rasterio.open(‘/my/path/ReferenceRaster.tif’) as src: ras_meta = src.profile with rasterio.open(‘/my/output/path/output_supervised.tif’, ‘w’, **ras_meta) as dst: dst.write(supervised) Where ras_meta is: {‘driver’: ‘GTiff’, ‘dtype’: ‘float32’, ‘nodata’: None, ‘width’: 1847, ‘height’: 1270, ‘count’: 1, ‘crs’: CRS.from_epsg(32736), […]