#algos-and-data-structs

1 messages · Page 75 of 1

fierce inlet
#

using one of these you can keep releasing the semaphore until there's no one left waiting.

#

and maybe do this in a mutex so no one else tries to acquire the semaphore while it's being flushed.

#

but there might be a better way, that wont be so implementation dependent.

royal kestrel
#

I mean sure

#

An Event is basically a Condition around a Lock and a flag

#

a semaphore is the same but instead of a flag it has a value

#

But you could definitely abstract around the value to only use 0 and 1 and broadcast events with it

fierce inlet
#

An Event is basically a Condition around a Lock and a flag feels the other way round too. that a Condition variable would be an Event and a Lock.

solid cloud
#

I mean, semaphore is the building block of a mutex

#

and mutex is the building block of thread-safe data structures that can tell you when new data arrives

#

so yes?

cursive frigate
#

Hey guys, sorry if this isn't allowed but I'm doing a college project on cyber-crimes. If you could take 2 minutes to fill it in, it would be greatly appreciated.

acoustic fox
#

THIS IS NOT ALLOWED

#

HOW FUCKING DARE - One sec, ganna fil this out before I continue

dawn eagle
#

@cursive frigate done. Some of the questions are a bit ambiguous. 'Have you been affected by...'. Well yes, there are bots hammering on ssh every few second; no, none have been successful. 'Do you use an anti-virus?' Well yes, Windows Defender is installed on all computers Windows 7 and up; no, I don't pay for shady garbage AV products.

#

Yes, I have received fraudulent emails; no I have not sent $2000 in Google Play cards to tech support scammers.

cursive frigate
#

Thanks guys, it's not that serious. It's just so I have some data to present. People reading it won't have a fucking clue what what's behind a prince of Nigeria email lol

acoustic fox
#

"have you ever been affected"

#

I would like a "I know know."

simple matrix
#

does anyone know

#

how to edit or create videos

#

with python?

fiery cosmos
#

Hey guys, I have known python as a Physics student for a while now, but recently I have
joined as a grad student in a CS department, and the people here are light years ahead of me in coding.
I feel I lack basic design principles and any understanding of OOP principles. I feel this is a gap which I cant fill just by programming
on my own, I need some technical guidance from a book with examples, which will let me design medium to large scale
software which are modular and neater. I really want to learn this in the most canonical-pythonic way possible.
Does anyone have any references ?

scenic mason
#

@simple matrix take a look at ffmpeg

gusty grove
#

@fiery cosmos unrelated, but have you done anything with gravitation in your physics classes?

acoustic fox
#

@fiery cosmos If you already mastered the fundemntals and know how to impliment classes, functions, basic control flow and whatever, go through "Fluent Python: Clear, Concise, and Effective Programming" (I am also a physics person going into CS) it's a great way to learn how to make hyper effective programs. I don't know if it gives you the complete structure of a program, but it's pretty f***ing good.

#

It wont teach you computer science principles with runtimes or advanced data structures like heaps, sorts, trees, linked lists, or graph structures, for that you should take MIT opencourseware into to algs 6.002? (fall 2011)

#

@gusty grove There are lots of ways you could be asking that question. You learn about basic gravity in your intro class. But that is without respect to relativistic gravity equations which is different from other stuff like how light deals with gravity or calculating tidal forces or how gravity waves interact with objects and give off momentum or whatever

gusty grove
#

Ok, specifically the n body problem

acoustic fox
#

Ah, I think you were on this a few days ago ?

gusty grove
#

Yup

#

Still am

acoustic fox
#

What about it

gusty grove
#

Well. What can I do with it, any tips etc

#

Like on the implementation side of things

acoustic fox
#

So, in physics a big part of understanding the dynamic interactions between objects is the continuous /non-discrete sum of their behavior over time

fiery cosmos
#

@acoustic fox do I know u?

#

I think you pinged wrong 🤣

acoustic fox
#

LOl

#

sorry Sagar

#

Now, @gusty grove There is a clear defined solution for the single body case where one object is completely stationary and the other object is moving

#

It's given by one equation

#

There are equations that satisfy the n <= 2 body problem

#

There are no equations that satisfy for the n>3 body problems

gusty grove
#

Yeah exactly

acoustic fox
#

Instead you have to approximate analytically

#

or discretely

gusty grove
#

Dont you just solve iteratively?

#

With a fixed timestep

acoustic fox
#

That is what discrete means

#

But you could do iterative continuous functions as well

gusty grove
#

Ah

acoustic fox
#

For instance, iterative integrals/derivatives wouldn't be discrete

#

SO as a naive/simple approx for your approach is you would calculate the aprox gravitational pull between each N object which gives you N! different gravities to approx

#

Then you calculate the discrete time step of that interaction

#

Then update the velocity due to accel

#

and then rinse repeat

#

Unfortunately it gets too big to calculate with n >15? objects

gusty grove
#

im doing the calculations on the gpu so i can go up to a few hundred/thousand

acoustic fox
#

I don't think that matters

gusty grove
#

how should i handle collisions?

acoustic fox
#

GPU doesn't solve this because the number of objects interacting with oneanother grows factorially

#

the number of interactions at 80 is larger than the number of particles in the known universe

#

So typically you use approxs to handle that many particles, and other tricks to reduce the problem size dramatically

#

You could handle collisions as Inelastic collisions

#

and total mass is just m1 +m2

#

You could also make them act like billiard balls

gusty grove
#

ah ok

acoustic fox
#

That's a different equation

hybrid crater
#

yo i'm doing a pretty Coding and Algorithms thing (my own implementation of the Wave Function Collapse thing) and i need someone who is good at the computers to help me figure out more efficient recursion stuff

#

if anyone likes this kind of stuff and has a minute to spare please ping me here and i'll send the details

acoustic fox
#

@hybrid crater

#

What's up

hybrid crater
#

okay the chance is basically zero but have you heard of wave function collapse

#

(the 2016 algorithm not the quantum thing)

#

(it's named after quantum thing)

acoustic fox
#

I'm looking it up now btw

hybrid crater
#

anyway i'm working on a python remake myself cause i feel like it

#

from a very cool person

#

(starts at useful timestamp)

acoustic fox
#

I get the concept

#

And now I know how to implement a naïve version of it

hybrid crater
#

so here's the highlights of how i'm doing it

#

(i'll get to the question bit dw)

#

make the 'cards' by chopping up the input

#

each card has a 'sphere of influence'

#

basically cards can affect things 2n-1 away

#

in both axis

#

so if we have 2x2 squares, i can affect things up to 1 away from the centre

#

3x3, affect things up to 2 away

#

does that follow

#

(like it works but does that explanation make sense)

acoustic fox
#

I am not sure why a 3x3 thing should effect things upto 2 spaces away

#

wait

#

from the center

#

Sure

hybrid crater
#

yeah

acoustic fox
#

That seems like a weird definition

hybrid crater
#

each 'card' is positioned so the top left is 0,0

acoustic fox
#

as opposed to say things can only effect edges

#

but whatever

hybrid crater
#

okay maybe that's my dumb thing

acoustic fox
#

no

#

It's fine

#

I presume diagonals are effected?

hybrid crater
#

yeah

acoustic fox
#

3x3 can effect 8 spaces

#

affect*

hybrid crater
#

nah 2x2 can effect 8

#

cause whilst it overlaps on the bottom right, it also has to get covered top left

#

3x3 hits 24

#

sounds like (2n-1)^2 - 1 to me btw

acoustic fox
#

Yeah you're right

hybrid crater
#

okay so we can precalculate card overlaps

acoustic fox
#

It's 2n-1 because that's how squares work

hybrid crater
#

like if this card were to be here, what can the relative cell (2,2) away be

acoustic fox
#

1,4,9,16,25

1+3+ 5 +7 + 9 . . .

hybrid crater
#

each card has an id, and then it has a 2d list of the acceptable cards away from it

#

vewy efficient, vewy nice

#

so we've precalculated everything about each card

#

so we've precalculated everything about each card

acoustic fox
#

I'm following you

hybrid crater
#

i'm calculating entropy as just 'how many options are there'

#

not the entropy formula but since we're calculating only one relative to another then nbd

#

(unless it is a bd without me realising since maybe original algorithm does something like comparing sums of them? who knows)

#

(the original algorithm calculates entropy as nlogn)

acoustic fox
#

UH

#

kln(n) where n is the multiplicity of states

hybrid crater
#

that

#

like this decision only matters for choosing which stack to collapse

#

i've seen another implementation that does it the naive way like me and it seems okay

acoustic fox
#

It's fine depending on what we are talking about

#

I would imagine you are trying to reduce the states with the lowest entropy

hybrid crater
#

yeah

acoustic fox
#

which then updates neighbors

hybrid crater
#

legit that just looks the prettiest apparently

acoustic fox
#

and then carries some right to left procedure or random

#

or whatever

hybrid crater
#

well the big deal is how we propogate the information

acoustic fox
#

It doesn't seem to be that big of a deal TBH

hybrid crater
#

so collapsing is obvious, choose a cell with the lowest entropy, and set all but one of its acceptable cards to false

acoustic fox
#

I am wondering for instance if it is possible to get into a state of contradiction

hybrid crater
#

yes

#

but it's just very rare

#

just happens to be

acoustic fox
#

But if that happens, you pull back/remix

#

or something

hybrid crater
#

true

#

well all the compute time for me is spent on propagating so i'll explain what i'm doing

acoustic fox
#

That seems like that wouldn't be that computationally intensive

#

It should be very easy

hybrid crater
#

you'd think

#

anyway the first thing i tried was basically

#
  1. try to update each cell in the sPhErE oF iNfLuEnCe (left to right, top to bottom)
#
  1. if an update needs to be made, then it could also affect other stuff, so run step 1 but from this new point as well
#

n=2 was kinda okay

#

but n=3 caused stack overflows

#

so much wasted shit

acoustic fox
#

Code ?

hybrid crater
#

so i switched to a queue thing

acoustic fox
#

Do you have a github?

#

I don't think queue is necessary

hybrid crater
#

mind if i put it on a hastebin

acoustic fox
#

It's whatevs

hybrid crater
#

well right now i just add everything to the queue, and instead of recursing the whole function i instead add stuff to the back of the queue

#

(if it's already there don't bother)

acoustic fox
#

My instinct is that everything can be done procedurally

hybrid crater
#

okay just for context

#

n=2 is a bit fast

#

n=3 takes like 11 seconds per collapse cycle

#

the original algorithm can do like 30 a second

#

so i can agree i'm doing something wrong

#

it's just the original was written like it was made in the 90s or some shit

acoustic fox
#

Do you know about graphs and relaxation ?

hybrid crater
#

i have heard of those words individually but not together

#

so let's go with no

acoustic fox
#

It's okay. It's tangentially relevant, the same solution for shortest path will I think apply to this problem which essentially is a graph problem

#

I'm just going through your code at the moment

#

Lol

hybrid crater
#

just one quick insight thing: part of the problem that i've found is that you often have to update things multiple times

acoustic fox
#

That's fine

hybrid crater
#

cause its surroundings can change

#

I'M SORRY THE CODE HAS BEEN THROUGH A LOT OF CHANGES IT PROBABLY LOOKS VERY CURSED RN

#

weird commented lines everywhere as well

acoustic fox
#

I could be wrong

#

But I think on average each pixel gets 3 updates

#

er

hybrid crater
#

like it SHOULD or it does?

acoustic fox
#

So what is happening is that you have an expanding boundary

#

and each pixel should only be on average be investigated 3 times

hybrid crater
#

did 3 come from a back of the napkin thing or is that hard maths

#

and does that apply to n=3 only or all n

acoustic fox
#

The average case is a straight line

hybrid crater
#

um

acoustic fox
#

If it is concave/convex it'll be more/less

hybrid crater
#

man that feels so correct but it feels wrong

#

also n=3 it would be affected from further away but like

#

okay here problem

acoustic fox
#

WAIT

hybrid crater
#

WAITING

acoustic fox
#

YOU ARE SAYING

#

OH FUK

hybrid crater
#

*quietly (so like, line a updates line b above it, which updates line c above that, but that may have ramifications for line a)

#

(that's the problem i'm having)

#

(n=4 is same problem +1)

acoustic fox
#

??!?!

hybrid crater
#

does that mean i'm dumb

acoustic fox
#

I am asking about the sphere of influence

#

That things can effect things from 3 lines out

hybrid crater
#

well 2 lines out

#

for n=3

#

but also it's not a sphere it's a square really

acoustic fox
#

You are growing problem exponentially then yeah?

hybrid crater
#

yes!

#

that's why i'm so confused as to how other people get it right!

#

n=2 runs at an acceptable speed

#

okay should probably be a bit faster but like

#

yeah

#

output is a linear problem

acoustic fox
#

It's still not that bad

hybrid crater
#

if i double the size of the output, it takes about twice as long

acoustic fox
#

TBH

hybrid crater
#

basically what am i doing wrong

acoustic fox
#

So, whenever you settle a tile (collapse it)

hybrid crater
#

i've done the profiling btw, it spends like all its time on that one bit where it compares the two lists

acoustic fox
#

You immediately update all effected tiles

hybrid crater
#

aka do these tiles overlap okay

acoustic fox
#

So when you check to collapse a tile, you never ever check for upates

#

you just run whatever state it is at and collapse it with the probability distribution

#

then you update tiles based on it's updated value

#

So lets say n = 3

hybrid crater
#

sorry are you telling me what is happening or what should be happening here

#

also by collapse do you mean 'making an observation' in the quantum phrasing

acoustic fox
#

What I think should be happening

#

I know quantum stuff

hybrid crater
#

i don't

acoustic fox
#

😛

#

I have a physics background

hybrid crater
#

that slaps haha

#

so like collapsing is the thing that happens first in the cycle

acoustic fox
#

SO in this case you are given a set of probabilities for a particular state

#

And you run the weighted probabilities and see what happens

hybrid crater
#

for the collapse?

#

or for the update?

acoustic fox
#

You take your weighted probabilities and run a random.randint + weighted prob or something

#

and see what it's collapsed state is

#

right ?

hybrid crater
#

yeah

#

like, different cards appear more or less often on the input

#

so i just have each card come with a count and do a weighted

acoustic fox
#

'cards' are just a particular type of input

#

or state

#

in this case

hybrid crater
#

'cards' are a NxN

acoustic fox
#

Sure

hybrid crater
#

so yeah state

acoustic fox
#

For your program that is what that means

hybrid crater
#

yes

acoustic fox
#

But i think what I am saying is true for all cases

hybrid crater
#

so collapsing is easy, that bit's not a problem

acoustic fox
#

What's the problem ?

hybrid crater
#

propogating

acoustic fox
#

?

hybrid crater
#

like, updating everything else

#

yeah sorry this is why i was confuse about terminology

#

there's an initial collapse for each iteration

#

that's where it makes ONE DECISIVE DECISION

#

and does something random

#

but then everything else that follows isn't random

acoustic fox
#

UHH

#

I don't think that is true

#

I mean, it can be true

hybrid crater
#

i'm like pretty sure it's true

acoustic fox
#

But if two states have the same lowest entropy

#

you need to choose one

hybrid crater
#

yeah

acoustic fox
#

You could do left to right

#

middle out

hybrid crater
#

you choose randomly between the cells of lowest entropy

acoustic fox
#

Farthest from the average

#

But that's a random choice

#

I'm just sayingh

hybrid crater
#

collapse bit isn't the hard part

#

that's definitely random

#

but the idea is you then propogate that information so that all the cells then know what is and isn't available anymore

acoustic fox
#

That seems really easy

hybrid crater
#

cause collapsing removes options, so a bunch of overlaps aren't gonna work anymore

#

yeah it seems easy but don't forget i'm an idiot

acoustic fox
#

Right

#

Well so am I

hybrid crater
#

hell yeah

acoustic fox
#

and remember, two wrongs don't make a right

#

Wait

#

There is nothing to go from there 😦

hybrid crater
#

to go from where

acoustic fox
#

UHH

#

so

#

BTW, saying everything has a bool value sounds dumb

hybrid crater
#

like from the screenshot

#

or from my code

acoustic fox
#

The screenshot

hybrid crater
#

yeah the phrasing is dumb

acoustic fox
#

your code requires an enigma machine

hybrid crater
#

my code is fine art

acoustic fox
#

fine rat is right

#

geeze

hybrid crater
#

fukin freudian keyboard there

acoustic fox
#

LOL

hybrid crater
#

it's also a mess cause i keep adding in logging elements

#

and all those globals need to go

#

cleanup comes after i figure out a better formula tho

#

my iteration thing right now is wack but i can't think of a better one

#

the queue thing seems alright in theory since it makes sure to deal with the priority stuff first

#

but like

#

it doesn't

#

i dunno how to figure out priority

#

cause everything affects everything

#

@acoustic fox i do warn you it's possible that i've just blinded you from seeing the really obvious explanation to the problem by explaining my solution

#

i do that a lot to people lmao

#

i was doing this question in physics about how long it takes the moon to orbit the earth and my teacher couldn't figure out what i was doing wrong cause i managed to convince her that it actually takes a year for that to happen

acoustic fox
hybrid crater
#

yes

#

wait where does gameboard come from

acoustic fox
#

OH GOD

#

this is getting complicated

#

but correct

hybrid crater
#

I KNOW I'M AMAZED I GOT IT WORKING AT ALL

#

this is like the first time i've done some proper sexy algorithmsss and not just fukin with the requests modules

brave sandal
hybrid crater
#

@acoustic fox uhh it's like sleep oclock where i am

#

thank you so so so so so much for the help

acoustic fox
#

Take a look at this

#

LOL

#

Basically each cell has a dictionary of possible states through bools or weighted values.

You have a dic that has a set of rules for each state on how it affects its neighbors.

You go through a list of affected neighbors and you update their cells internal rules through the dictionary calls.

hybrid crater
#

yup

acoustic fox
#

You still have to perfrom ~ n^2 checks

#

but that isn't bad

hybrid crater
#

wait

acoustic fox
#

what

hybrid crater
#

uhh

acoustic fox
#

UHH

hybrid crater
#

so you only go through each cell once?

acoustic fox
#

We collapse cell (1,2)

#

It updates each adjacent cell within its square of influence once

#

Then we add those adjacent cells that are updated into the priority queue of cells that need to be collapsed

hybrid crater
#

so far so same

acoustic fox
#

if 0,0 updates ((0,1),(1,1),(1,0) you update the priority queue and then you go through things one by one

hybrid crater
#

wait what

acoustic fox
#

what

hybrid crater
#

cells that need to be COLLAPSED?

acoustic fox
#

WAVE FUNCTIONS COLLAPSE

hybrid crater
#

but but but

#

that not how the formula wokr

acoustic fox
#

Yeah it does

hybrid crater
#

you haven't updated the entire output yet

acoustic fox
#

You update one cell at a time

#

What do you mean

hybrid crater
#

like

#

okay

#

hang on

#

when you say collapse, do you mean choose one at random?

#

and make that the only option?

#

cause you can only do that when you KNOW the rest of the board is okay

acoustic fox
#

You choose cell 0,0
You collapse cell 0,0.
-> you update cells (0,1),(1,1),(1,0)
You add those cells into the priority queue of the next cells to be collapsed
[(0,1),(1,1),(1,0) ]
You update (0,1)
you update cells [(0,2,) (1,1),(1,2)]
You add them to the priority queue

[(0,1),(1,1),(1,0), (0,2,),(1,2)]
you sort by lowest entropy
[,(1,1),(0,1),(1,0), (0,2,),(1,2)]
You update (1,1)

#

Repeat

#

(This is if n = 1)

hybrid crater
#

i'm lost

acoustic fox
#

??

hybrid crater
#

n=1 is no overlap

acoustic fox
#

1 reach

#

is that n =2?

hybrid crater
#

the size of the patterns you get from the input is NxN

acoustic fox
#

Fine

#

reach 2

hybrid crater
#

well yeah 1 reach n=2

acoustic fox
#

You can define things by their reach or their space from the center

#

In this example I have boundaries that you can't have negative numbers

#

starting from the top left of a square in this case

#

Just to make it simpler

hybrid crater
#

but i need to clear up

#

when you say collapse

#

do you mean choose something at random

acoustic fox
#

Collapse means you define the state of the celll

hybrid crater
#

or do you mean update the cell according to its neighbours

acoustic fox
#

By random, by probability, by discrete choice, it doesn't matter

#

if you collapse a cell, it becomes the state of 'sand'

#

and it isn't probabilistic/anything else anymore

#

It is fixed

#

And it should never change ever again

hybrid crater
#

but the algorithm doesn't work by just collapsing cell after cell, it has to update the whole board inbetween

acoustic fox
#

....

#

It does update the baord

#

board*

#

When you collapse a cell, it updates every other cell it can reach

#

Then you go onto the next cell

hybrid crater
#

but you can't just update 0,1 1,1 and 1,0, cause you also need to update the neighours of THOSE

acoustic fox
#

??

hybrid crater
#

their neighbours will also be affected

#

trust

acoustic fox
#

You are saying a -> b - > c?

hybrid crater
#

where a b and c are ?

acoustic fox
#

cells

hybrid crater
#

and arrows are

#

like there's a knock on effect yeah

acoustic fox
#

What is the range of A?

hybrid crater
#

say a can only reach b

#

and b can only reach c

#

there's still a knock on

#

if n=3 then maybe a can reach c and then it gets even harder

acoustic fox
#

So

hybrid crater
#

but a change to one cell effects more than just its neighbours

acoustic fox
#

This is still fine

#

I mean

#

Computationally it's going to explode because you are getting into !n territory

hybrid crater
#

yeah

#

that's the problem innit

#

but somehow people do it right

acoustic fox
#

It's not doing it right

#

they take approx

#

It's a graph problem

hybrid crater
#

sorry how do you approximate whether patterns overlap

acoustic fox
#

You have 3 paths to D

#

If we assume letters aren't self interacting

hybrid crater
#

sure

#

they're not btw

acoustic fox
#

because technically c -> b ->d ->c again

#

And you can use an integral / infinite series to get an analytical solution

#

but fuck that

#

In this case

hybrid crater
#

so what's the insight

acoustic fox
#

Are these valid paths ?

hybrid crater
#

yeah you're starting to see the problem

acoustic fox
#

It's not really a problem

hybrid crater
#

the relationships are complex and everything needs to be updated from all angles

#

hence a recursive technique

#

ohh

#

ohhhh

#

wait no i very nearly had it

#

fuk i need to do sleep

#

or i'm gonna die

#

if you have any more magic thoughts on this please do send

#

also btw this algorithm is literal magic it has so many untapped possibilites

#

my favourite is that you can have one axis be time

#

no one has made game of life yet but i'm convinced it's possible

acoustic fox
#

If you find a new valid configeration

#

that's a wikipedia entry for you

hybrid crater
#

someone get on it

#

who is better than me

#

okay gonna fukin slep

#

thank you so much for doing brain

#

whenever people of your culture sleep i hope it's really great

acoustic fox
#

Is a white paper describing the process

#

I think the way you are describing is just a particular way you value possible outcomes but is not endemic to the process as a whole

hybrid crater
#

FUK I SAW THAT PAPER AGES AGO BEFORE I'D FINISHED THE FIRST WORKING VERSION

#

THAT IS VERY HELPFUL

#

THANK YOU VERY MUCH

acoustic fox
#

Yah

#

NP

hybrid crater
#

okay that's my takeaway now i go die

acoustic fox
#

my algo is basically what is described in the paper

#

Gl

#

Hope you live again

hybrid crater
#

also go play caves of qud it's why i'm doing this in the first place

#

byeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

#

thank you :)))

agile summit
#

New channel?

last blaze
acoustic fox
#

You have me to thank! >:DDDD

#

First rule of computer science channel, don't talk about computer science channel

tribal pendant
#

Hello, what's the best module to solve differential equations on python?

gusty grove
#

@acoustic fox ha! it works

#

Unfortunately it gets too big to calculate with n >15? object
as if! i can go up to n=10**5 easily with a dt of 1/1000

#

and well even smaller dt for smaller N

#

gpus really are amazing

#

im not handling collisions and just using a cutoff to avoid zero division so the system does lose energy on collisions

#

gonna have to fix that

acoustic fox
#

Hellya

#

how are you using a GPU?

#

Cuda?

gusty grove
#

Opengl yup

acoustic fox
#

How did you deal with the reflection issue ?

stark bridge
fiery cosmos
#

@acoustic fox Thanks alot. Went over the reviews and index so far , seems exactly the book I was looking for

gusty grove
#

@acoustic fox whats that?

acoustic fox
#

@gusty grove

#

Butt out

#

I help more people than just you

#

♥️

fiery cosmos
#

@acoustic fox This book is fucking insane, chapter one is teaching me much more about all frameworks I have ever used than all frameworks i ever used did ! ;D

outer lake
#

Fluent Python is my favourite Python book. There's a new edition coming out in a couple of months that updated to Python 3.8.

#

Still, the current version is still really relevant

#

Although the chapter about coroutines is in need of an update, since it uses pre-async def/await syntax (yield from and generator.send)

acoustic fox
#

Yeah

#

Fluent python is all that and a bag of chips

gusty grove
#

@acoustic fox well you haven't really helped me yet, why don't you Start? ;)

sharp crest
#

Is there any good libraries to compare audio features between two files?
Like comparing 1s of one file to 1s of another or something like this

#

the task of first extracting the signal with FFT and then plotting it on a spectogram myself seem a bit daunting tbh

gusty grove
#

There are some great fft libs out there :)

#

And matplotlib is great for plotting

#

Numpys fft

acoustic fox
#

LOL

#

I drew you a pretty gravity picture, that counts.

#

more fluent python for me today.

tribal pendant
#

@stark bridge Ty, but I was more looking at a method to generate approximate functions rather than a tool that tries to "solve it" formally (because it's impossible to solve), but that's my fault I didn't specify enough my question 🙂 Ty anyway!

#

For those who are interested, I used scipy.integrate.odeint and I did the work.

long sleet
#

Could someone explain me how is an audio file encoded on the PC? what does the PC read? the MHz on each point for different channels?

#

cuz as far as i know, it only sends pulses to the speaker

#

and the speaker moves according to them

#

so what are the different channels for?? to make the sum on each point and send that result?

half lotus
#

Putting aside all the container formats and different compressions, look up PCM

#

Multiple channels is so different signals can be played simultaneously

long sleet
#

how is gonna a single speaker play different channels at once???

half lotus
#

You can't unless you have electronics to combine them together

#

It's useful when there are multiple speakers e.g.headphones

spice ravine
#

usually you have two channels for two speakers i.e. left and right

acoustic fox
#

@long sleet So it's actually the case that you can approximate any signal through an infinite sum of sine waves

#

a FFT breaks down a signal into sine waves and transmits their coefficients (2? I think?) and that is what is what is stored on your computer. So once you have a format of coefeccients it is easy to reproduce the sound by reversing the FFT and recomposing the signal into AC and then driving a speaker

#

You can have a speaker play multiple 'channels' if you want

#

But then you move from having a dual/stereo system (where audio is coming from two sources) into a mono system. (Audio is coming from one source) It's very easy to take two signals and combine them

long sleet
#

okey, maybe my question was bad

acoustic fox
#

Encoding audio files is different/tricky because with a FFT you are dealing with infinite sums, some coefficients aren't that important so you discard them

long sleet
#

what is the difference between an song from nowadays and a 8-bit song?

#

what do those 8-bit represent?

#

cuz i know normally songs have 44100 points per second

#

iirc

spice ravine
#

ok, 8 bit usually means

#

not 8 bit literally in terms of sample size [though that does exist]

long sleet
#

ye ye xD i supossed that ahahah

spice ravine
#

but people say "8 bit" when they mean "the style typical of 8 bit game systems"

acoustic fox
#

8 Bit doesn't mean sample size I believe ?

spice ravine
#

yes it does, sample size is usually either 8 bit or 16 bit

acoustic fox
#

That ...doesn't actually make sense TBH

spice ravine
#

8 bit can be linear, µ-law, a-law, etc

acoustic fox
long sleet
#

does the 8bit has anything to do on the ammount of points stored?

#

or the maximun value they can have?

spice ravine
#

yes what i'm saying is there's also legitimate 8 bit sample size pcm

acoustic fox
#

8 bit sample at 200 hz is going to be 1 bit sample at 1600 hz

spice ravine
#

thats not how it works

acoustic fox
#

I know

#

That is why it doesn't make sense

long sleet
#

okey, my question came when ive listen an anime opening on 8-bit format xD

#

how is that made?

#

taking the original and reducing the quality

#

or recreating the original as if it was 8-bit?

acoustic fox
#

I don't know if 8 bit represents the total tonal output

long sleet
#

or that can be done in both ways?

acoustic fox
#

or the aplitude of the output , I think it is tonal frequencies ?

spice ravine
#

like i said the term "8 bit" has several different meanings

long sleet
#

how is that made?

spice ravine
#

@acoustic fox pcm doesn't encode frequencies directly at all, it just encodes the voltage sent to the speaker at each moment in time, the signal goes up and down to represent a frequency

long sleet
#

modifying the original or recreating it?

spice ravine
#

yeah that's something someone recreated

long sleet
#

and can u modify the original to get the same result?

#

btw i think the 8 bit is the tonal difference

spice ravine
#

probably not

#

...i don't know what you even mean by "tonal difference"

acoustic fox
#

UHH

spice ravine
#

but anyway, that music is clearly in NES style specifically

long sleet
#

the amount of different sounds u can make

#

XD

acoustic fox
#

I was guessing that you could only output 255 frequencies ???

#

But that is probably not true

#

I'm thnking

spice ravine
#

the NES could generate two square wave instruments, one triangle wave, and one white noise signal

acoustic fox
#

@spice ravine 'Measuring voltage' You are still talking about sampling times

spice ravine
#

huh? i wasn't talking about sampling times before so idk what you mean

acoustic fox
#

50k HZ sample time at 8 bit is completely different than 10hz sample time 8 bit

spice ravine
#

ok but you were talking about sound frequencies, the sample time is fixed, so i don't know what you mean by "tonal frequencies"

acoustic fox
#

8 bit is the resolution of possible amplitudes of a given sample time

spice ravine
#

right

#

or 16 bit

acoustic fox
#

or 24

#

or whatever

spice ravine
#

it's usually 16 bit on modern systems

acoustic fox
#

It just depends

spice ravine
#

ok anyway

#

i guess we've lost track of what the question is

acoustic fox
#

(I deal with microcontrollers and I see a lot of options,e ct)

#

(Neither here or there)

long sleet
#

so the bit are the samples?

acoustic fox
#

Yes

long sleet
#

or the

#

volts?

acoustic fox
#

Do you know what a sine wave is?

#

sine*

long sleet
#

ye

acoustic fox
#

So lets say your sine wave amplitude is 10

#

If 8 bit was a ruler, it would be only able to measure 255 levels of that 10 amplitude signal

#

So if you straight up record and output the signal without analysis, it would output in increiments of .04 *amplitude steps

spice ravine
#

ok but there is still some confusion

#

because the 8 bit you asked about, like, that sword art music you linked,

#

has nothing to do with 8 bit pcm samples

#

it's basically just emulating the style of the NES which is an 8 bit game system

acoustic fox
#

^ Random knows what they are talking about

#

8 bit modern is not constrained to the 8 bit systems that existed

#

8 bit is a style now which is not constrained

long sleet
#

sorry for the delay

#

so the NES was an 8 bit system

#

what does that have to do with the sound?

acoustic fox
#

Means that the NES has only 255 colors it can put on the screen I believe

long sleet
#

even if u dont understand anything from the vid (not ur language)

#

go min 2.30

#

ff is 8-bit and zelda is 16-bit

#

i mean, there is clearly a difference between them

#

but i dont know exactly what

pallid coral
long sleet
#

what i wanted to know is the difference between a final fantasy OST from now and from the one on 1990

pallid coral
#

Now: PCM encoded in music files

#

Then: 6502 instructions sent directly to sound generating chip in game system

tender wedge
#

Small trolling: None just the composer plagiarizing himself over and over

acoustic fox
#

Original zelda was 8 bit

long sleet
#

what ever. I just want to know the difference in terms of encoding uwu

amber dagger
#

hey, not sure if this is any place to ask since it's just python, and feel free to chuck me a server if there's a better one for my question

#

I'm having trouble with an assignment on information systems & databases, questions include tech stacks, ERDs ect, and having a tough time understanding some questions

#

the question in particular:

#

Research the data model of an organisation by looking at their API documentation and any other sources of publicly available information and describe the organisational functions that are possible based on the API.

gusty grove
#

if you take n random steps in a grid world you will travel an average sqrt(n) right?

royal kestrel
#

running simulations it seems to be ~ 2.5 * sqrt(n)

gusty grove
#

are you allowing diagonal movement?

acoustic fox
#

UH

#

Is that true?

#

Wouldn't the total average be 0

#

I mean, you'll probably never hit the origin again in a 2d grid

#

But random walk in one direction about 0 is invariant to the random walk in another direction about 0

gusty grove
#

A random walk is a mathematical object, known as a stochastic or random process, that describes a path that consists of a succession of random steps on some mathematical space such as the integers. An elementary example of a random walk is the random walk on the integer numbe...

#

P(r) = (2r)/N*e^(-r^2/N)

#

step length N is 1 in my case

#

so P(r) = 2r*e^(-r^2)

acoustic fox
#

That's the probability distribution

gusty grove
#

yeah

#

and it will fall off pretty quickly from what i can see

acoustic fox
#

The space grows r^2

#

so I would imagine

gusty grove
#

you are right for 1d

#

goes to 0

#

but for 2d it goes to the last limit

acoustic fox
#

UH

royal kestrel
#

@gusty grove no diagonals

acoustic fox
#

The absolute average distance is different than that average displacement

#

I think

#

Maybe I am just wrong

#

But if you imagine walking around in a circle of some given radius

#

Your average displacement is the radius but your average position is 0

trail light
#

Ok what is this stuff

#

😳

devout helm
#

anyone know how to find C in this?

#

im rusty with math lol

late scaffold
#
def functionjj(n):
  for i in range(n):
    if i == 0:
      for j in range(n):
        for k in range(10000):
          print("string")
#

What is the asymptotic time complexity of functionjj with respect to n?

devout helm
#

whats the question @late scaffold

#

oh

#

O(log3 n)?

half lotus
#

It's just n I think, assuming n > 0

#

if i == 0 means the for j in range only runs once in total

late scaffold
#

Write answers as a polynomial of variable n in the standard form (eg 10n + 5, 50n ^ 2 + 3n + 30, or n). Be sure not to use the * symbol.

half lotus
#

and the inner most loop is just a constant so that can be omitted

#

You can't just copy paste your homework questions here and expect help

#

You need to try them yourself first and ask specific questions

late scaffold
#

I've been dealing with it for hours, and I don't know anymore

devout helm
#

well i think its

#

O(log^ 3n)

#

because each for

late scaffold
#

with *

devout helm
#

is O(log N)

half lotus
#

Did you miss the if i ==0?

late scaffold
#

brainfu*k

#

def function(n):
for i in range(n):
for j in range(n):
for k in range(10000):
print("output")

devout helm
late scaffold
#

the if

late scaffold
#

😭

devout helm
#

been a while since i've done that.

#

the second link should help

#

since your not aloud to use the *

gusty grove
#

@devout helm square both sides, subtract 50^2, divide by 30 and then take the square root

gusty grove
#

in this case c is 30

#

*20

tribal pendant
#

it's absolutely not 20

#

nor 30

#

it's 20*square(10) ~ 63

#
>>> from math import sqrt
>>> sqrt(50**2+20**2*30)
120.41594578792295
>>> sqrt(50**2+30**2*30)
171.75564037317667
>>> sqrt(50**2+(20*sqrt(10))**2*30)
350.00000000000006
>>> sqrt(50**2+63**2*30)
348.66889737973474
#

@devout helm

gusty grove
#

well to be exact it has two solutions

#

one at +20*sqrt(10) and one at -20*sqrt(10)

#

the blue line is 350 and the purple one is your equation

pallid coral
#

350 = sqrt(50^2 + c^2(30))
350^2 = 50^2 + 30c^2
350^2 - 50^2 = 30 c^2
(350^2 - 50^2)/30 = c^2
+/-sqrt((350^2 - 50^2)/30) = c

#

-> ±20√10, or ±63.2456

orchid blaze
#
350 = sqrt(50^2 + (30)c^2)
350^2 = 50^2 + (30)c^2
350^2 - 50^2 = (30)c^2

(350 - 50)(350 + 50) = (30)c^2     # Difference of squares
120000 / 30 = c^2

c = +/- sqrt(4000)
c = +/- (2 * sqrt(1000))
c = +/- 63.2455532034
#

Factorizing it makes it a lot easier to do in your head because in a lot of cases you wouldn't need the decimal answer, you can just use "+/- (2 * sqrt(1000))"

desert cedar
#

** is the power operator

#

^ does a bitwise xor

low palm
#

I don't think it was meant to be read as python code, just math. If it was python then 350 = sqrt(50^2 + (30)c^2) is an illegal assignment, and numerous other problems

subtle agate
#

Who has the fastest pc?

gusty grove
#

At 148.600pflops "summit" is the fastest currently

#

Not really a surprise but it belongs to the usa

#

@subtle agate

subtle agate
#

Yes

gusty grove
#

Ok

subtle agate
#

Anybody with fastest gaming pc

gusty grove
#

Probably ask that in a ot channel

tender wedge
#

I took a fast train with my computer

#

At 400 km/h i had probably fastest pc ever

gusty grove
#

Ive taken my laptop on a plane

tender wedge
#

Ah damn

#

Then you have the fastest computer

last blaze
#

My guess is the raspberry pis on the iss are faster

warm marsh
#

Speed is relative anyway.

frank nest
#

^

#

What if tachyons also have computers?

granite monolith
#

hi!

gusty grove
#

Hi!

heavy nimbus
#

Hey

stark bridge
#

🐱

polar saddle
#

wait

#

do yu guys know how to program

trim apex
#

Imagine asking if people in a programming discord server know how to program

eager hamlet
#

lol

sly cove
#

what do u mean @trim apex I thought we're learning witchcraft

tame citrus
#

Well fair question, some are still learning

zinc birch
#

Anyone has an idea where to start learning about machine learning coding

#

?

#

I can find a source to learn from

#

I've heard about NEAT and Q-learning

#

but I can't find a course or something else to do it

#

and learn it

#

any help?

last blaze
#

just checked thee pins - looks like some good links

long sleet
#

Is this a channel to ask for maths?

gusty grove
#

sure

tacit moss
#

so this is a dumb problem, but how do I compute (x * c**d) % y where c**d is way too big to fit in an integer (and I need the precision that I would lose using a float)

warm marsh
#

use the built-in pow function with its third parameter instead of ** and %

#
pow(x, y, z=None, /)
    Equivalent to x**y (with two arguments) or x**y % z (with three arguments)
    
    Some types, such as ints, are able to use a more efficient algorithm when
    invoked using the three argument form.
tacit moss
#

but can I simplify (x * c**d) % y to x * (c**d % y) % y?

warm marsh
#

I think yes, but let me check again

brave oak
#

I believe ab % n === ((a % n)(b % n)) % n...?

spice ravine
#

that's how the algorithm works anyway

#

aiui it calculates the "exponent" by multiplying and taking the mod at each step so the intermediate result never gets big

warm marsh
#

right

spice ravine
#

[i.e. pow(x, y, z) itself is (((x%z)(x%z)%z)(x%z))%z etc]

tacit moss
#

hmm...well alright. I feel like there's something more to it though

#

thanks

uneven root
#

@tacit moss

is way too big to fit in an integer

Just as an FYI, ints in Python are effectively without a limit, (unlike most languages) so this typically isn't a concern. It's not like C or Java where there's a fixed maximum.

tacit moss
#

you say that, but it seems to be chugging on -19204542550164141017840894367007800359160643584000000000000000**101741582076661

stark bridge
#

@tacit moss so I take it you don't want to use the built-in pow?

tacit moss
#

I did! It seems to work...when I raise things to 1 and 0 but my solution isn't working for higher numbers (although I don't have much of a reference). I'm not sure if it's a problem with my math though

stark bridge
mossy shard
#

Could someone help me solve a problem in C?

native jungle
#

Hello there, i don't know if this channel is the right one but i would have a question

#

I learned python and i love it but i would like to try some App development. I already know the Javascript basic(var, functions, objects and etc.) and a little c++

#

Could someone give me some Tipps and tell me what he/she thinks would be better to concentrate on?

acoustic fox
#

That might be better suited for data-science

mossy briar
#

!paste

halcyon plankBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

spiral swallow
#

@native jungle what kind of apps? web? mobile? desktop?

native jungle
#

Mobile

balmy siren
#

Hey, i've a merge sort algorithm written in python
so i just want to check out the time complexity of merge_sort algo.
here's the code

def merge_hard(array):
    """ time complexity -> O(n+n+n) in worst case
    >>> merge_hard([3,4,5,2,1])
    [1, 2, 3, 4, 5]
    """ 
    center = len(array) // 2
    left_array = array[0:center]    # O(n)
    right_array = array[center::]   # O(n)
    i = j = k = 0

    # Find the smallest between these two sorted arrays 
    sorted_la = sorted(left_array)  # O(n)
    sorted_ra = sorted(right_array) # O(n) 
    # NEED TO BE CONFIGURE 

    while (i < len(sorted_la) and j < len(sorted_ra)):
        if sorted_la[i] < sorted_ra[j]:
            array[k] = sorted_la[i]
            i += 1
        else:
            array[k] = sorted_ra[j]
            j += 1
        k += 1
    while (i < len(sorted_la)):
        array[k] = sorted_la[i]
        i += 1
        k += 1
    while (j < len(sorted_ra)):
        array[k] = sorted_ra[j]
        j += 1
        k += 1
    return array

is the time complexity of this function is O(n+n+n) ??

acoustic fox
#

LOL

#

UH

balmy siren
#

what happend now?

#

am i doing something wrong?

acoustic fox
#

I might be the only person up

#

so you'll need to wait a day to get an educated response

balmy siren
#

ohhokay .. but what are thought on this ?

acoustic fox
#

I'm looking

balmy siren
#

okay

acoustic fox
#

I could be wrong

balmy siren
#

for what?

acoustic fox
#

But I think you need to reinitialize the second and third while loop

#

I think ( i >= len(sorted_la)

#

when you enter the second while loop

#

You might need to reset i = 0

#

just as an FYI

#

the second while loop = 0(n/2) and the third while loop = 0(n/2)?

#

so the total order for those two while loops together would be 0(n) ?

balmy siren
#

ohh .. why i make a use of last two while loops is because ..

suppose, you have a list of 5 element and you break it into two parts. Now 
a = [7, 9]; b = [3,2,1] 
okay, so in the first while loop i'm comparing elements of both the list and overwrite the orignal list .. but what if, one of these two list (a and b) have done comparing with all elements of other list. 
i mean,
1. 7 -> 3
2. 9 -> 2
now, our first while loop stop getting executed because i of first list is now equal to the length of a i.e., 2 and there's one element left in list b i.e., 1 which isn't compare by anyone else .. 
so that's why i put these two loops after the main while loop

You understand it ?

#

@acoustic fox isn't is now O(n logn) ??

#

You might need to reset i = 0
No, no need to reset i = 0 because if we do this then we start from the 0th index of the list and let suppose, the element which isn't compare by anyone exist on 5th index and now we just directly overwrite the orignal list by that element without comparing..
so that's the reason of why not reset the i after the first while loop

acoustic fox
#

UHH

#

I am not thinking clearly

balmy siren
#

no worries at all

scenic iris
#

@balmy siren is that some kind of college assignment ?

#

if so, then you probably want to re-write you merge sort

#
sorted_la = sorted(left_array)  # O(n)
sorted_ra = sorted(right_array) # O(n) 

1st it's wrong estimation since sorted function of python implements Timsort which is O(nlogn)
2nd typically if your challenge to implement merge sort you are expected to do a classic version of it, where you do it in recursive manner splitting your array until it's 1 element and start merging it back

balmy siren
#

@scenic iris no of course not

#

@scenic iris i also use Recursion to implement merge sort

#

Wait let me put it here

#
def merge_sort(array):
    if len(array) < 2:
        return array
    center = len(array) // 2
    left = array[0:center]
    right = array[center::]
    merge_sort(left)
    merge_sort(right)
    return merge(left, right, array)

def merge(left, right, array):
    i = j = k = 0
    while (i < len(left) and j < len(right)):
        if left[i] < right[j]:
            array[k] = left[i]
            i += 1
        else:
            array[k] = right[j]
            j += 1
        k += 1
    
    while i < len(left):
        array[k] =  left[i]
        i += 1
        k += 1
    while j < len(right):
        array[k] = right[j]
        j += 1
        k += 1
    return array
scenic iris
#

yeah, that looks better

balmy siren
#

but what if, i sort the first divided sub-lists then i don't need to further division of sub-lists .. but is it right to do so?

scenic iris
#

kinda again, if you want a classical implementation you divide until it's 1 element

#

e.g shell short has best sorting performance but only when it comes to data sets < 1000 elements

#

so you can do something like divide until array has len() <= 1000 elements then apply shellsort

unborn gazelle
#

So ive only recently began learning to code. Ive learnt a little bit of python, but i am wondering what coding language is best suited for game creation? because after my python course is over i planned to learn C#

feral shale
unborn gazelle
#

@feral shale thankyou

silent locust
#

hey, i have a basic math question. I am trying to write down |x-y| (where the difference is always positive), however, I do not remember how it is called in english -> can't properly look it up

warm marsh
#

absolute value?

silent locust
#

savior.

#

cheers!

split robin
#

Ok so I have a problem with understanding Hoare's partitioning scheme for Quicksort. I made myself a small example list so I can play around with it and to understand it. The list is the following: 0 1 2 6 1 5 3 4 9 8 1 2 0. In the first iteration, the Pivot is at index 0 + (12 - 0) / 2 = 6, meaning its the 3. After applying the scheme, which pseudocode looks the following:

algorithm quicksort(A, lo, hi) is
    if lo < hi then
        p := partition(A, lo, hi)
        quicksort(A, lo, p)
        quicksort(A, p + 1, hi)

algorithm partition(A, lo, hi) is
    pivot := A[lo + (hi - lo) / 2]
    i := lo - 1
    j := hi + 1
    loop forever
        do
            i := i + 1
        while A[i] < pivot
        do
            j := j - 1
        while A[j] > pivot
        if i ≥ j then
            return j
        swap A[i] with A[j]

the partition function returns the index 7 and the list looks like this if I did nothing wrong: 0 1 2 0 1 2 1 3 9 8 4 5 6.

#

Now when doing the next iteration I encounter the following problem on the left list which looks like this: 0 1 2 0 1 2 1. Here the pivot is at index 0 + (6 - 0) / 2 = 3, meaning its the 0. Now my brain cant get this to work. Going by this scheme it should do the following:

Stop the i incrementing loop, as 0 < 0 is false. i = 0.
Stop the j decrementing loop, as 0 > 0 is false. j = 3.
Swap.

This basically changes nothing

#

Would I just let the algorithm check for <= or >= at some point?

#

not that it would change anything

#

nvm... Would I just let the algorithm check for == at some point is the question

#

in that case i could skip the entry and continue

#

or something

split robin
#

ah yes got it. I need to check if the items at these indices are equal when i >= j is false. If thats the case, I'd need to increment i or decrement j until I find a respective item for a swap

#

Sorry for walling this channel ^^

split robin
#

thinking about it further i forgot how incrementing works

#

at least I know that my question was lead by the misconception that i and j would be reset to lo and hi....

#

oof

tacit nymph
#

Why are my odds of getting a good grip on the practical(coding) side of machine learning with very little experience with python?

stark bridge
#

if you have plenty of experience with other languages, probably fine.

#

If not, you're gonna have trouble

tacit nymph
#

My problem is practice.

#

Any website where I could practice. (I don't have a problem with theory)

#

Thx for your feedback

last blaze
#

Kaggle?

brave oak
#

@tacit nymph what kind of machine learning are you looking at?

tacit nymph
#

I'm following a book : Python Machine Learning by Sebastian Raschka and Vahid Mirjalili

#

But for now, I'm mostly reviewing concepts I saw 2 years ago in an udemy course

brave oak
#

no, I mean what methods

tacit nymph
#

Basic perceptrons

brave oak
#

do you want

#

okay

#

what I mean to ask is

#

do you want practice with the engineering part i.e. implementation of learning methods

#

or with the science part i.e. experimentation on how to solve a business problem using those implementations?

tacit nymph
#

Engineering part plz

devout wedge
#

does anyone know about nmos and pmos transistors

hazy geyser
#

yes

warm marsh
#

I guess that would be more fitting in #microcontrollers than here. Anyway, just ask your question, don't ask for people.

devout wedge
#

second left is right but why isn't second right

hazy geyser
#

second right is A or B

#

Question is asking about A and B

devout wedge
#

wait whattt

#

is AND when its within the same "line" and OR when its separated?

#

but im still confused actually

hazy geyser
#

IF and only IF

#

So that second left only has connection IF AND ONLY IF A and B are high

#

But the other, can have a connection when A and B are high, but also ANOTHER way of making the connection work

devout wedge
#

OHHHHHHHH

#

thanks my dude <£

#

❤️

hazy geyser
#

Lol np I hope I'm right I havent done this shit in 2 years

devout wedge
#

i'm going to go with your answer as it makes logical sense

hazy geyser
#

🙂

acoustic fox
#

Since this is a logical question

#

Having a logical answer is a+

lunar pivot
#

Does anyone know where I can read something useful about encoding (utf-8, ascii etc.)?

#

Or its's not very useful and I should focus on learnign some other things?

acoustic fox
#

You should know what it is

#

Different encoding types will come up and you should be able to recognize which type you are dealing with which will give you a clue to how to solve some issue

#

Learning how to encode matters more with C level programming or whatever

stark bridge
torpid thicket
#

not sure if this is the right channel but. But say you have an equation to denote a propagation rule, A = X + Y, but change what Y means and you write a new rule A = X + Y

#

Should you change the variable name, or add a hat?

#

and what if you have another iteration, can't really add another hat

hallow isle
#

Hey does anyone know a good C++ IDE that uses the Clang compiler?

royal kestrel
#

I think visual studio, CLion and QT Creator all have options to use the clang compiler

wind idol
#

not sure if you want an online ide though

fiery cosmos
#

wow.. pretty cool

#

how do you commit back to github

stark bridge
#

you don't.

#

you commit locally; then you push to github.

fiery cosmos
#

I dont get it

half lotus
hallow isle
#

Thanks

fiery cosmos
#

tips on how to reverse engineer my code into a flowchart?

#

ive never done it before bit lost

acoustic fox
#

Yeah

#

@fiery cosmos Flow charts are a mixture of design + engineering.

#

Engineering usually benefits from a top down approach where there are fuzzinesses around the edges when one engineering discipline intersects another or needs to make compromises around non discipline components of the project

#

Design is a vastly different approach where you make progress through (rapid) iteration. There are many ways to skin a cat and what you do is try a few different ways, figure out which approach is best, take the case which is the best, repeat until you get to a solution that is 'good' for your use case

#

In this example, use paper or a white board, start taking functions/whatever you are trying to flow and just draw it out and try to make it complete as possible. You will come up with an absolute mess.

#

You'll then need to reorganize and after you understand a bit about the underlying structure, you take your shit and do it all again. This time you are probably 80-85% there

#

You will notice mistakes and it's probably good to write down all the mistakes in a 'bug fix' list and then when you do the next update, you address each mistake.

#

Occasionally you'll find through this process that some pieces just don't makes sense together and you'll have to wonder why things work out the way it does.

#

--
flow charts are only as useful as their function of doing something. Making something pretty for nontechnical people to show you are doing work is going to yield a different flow chart than clearly explaining lets say the data flow through a program

#

--
Sumory -> Rough sketch -> organize -> refined sketch -> reorganize. ->repeat

fiery cosmos
#

okay thanks

fiery cosmos
#

'''h'''

#

'''css

#

' u '

#

'f'

bronze gazelle
#

@fiery cosmos are you ok?

unique jasper
scenic mason
#

Can we get some code?

jovial creek
#
class Neural_Network():
    def __init__ (self):
        self.inputSize = 3
        self.outputSize = 1
        self.hiddenSize = 2
        
        self.W1 = np.random.randn(self.inputSize,self.hiddenSize)/2
        self.W2 = np.random.randn(self.hiddenSize,self.outputSize)/2

    def forward(self,x):
        self.z = np.dot(x,self.W1)
        self.z2 = self.sigmoid (self.z)
        self.z3 = np.dot(self.z2, self.W2)
        o = self.sigmoid(self.z3)
        return o

    def backwards(self,x,y,o):
        self.o_error = y - o
        self.o_delta = self.o_error*self.sigmoidPrime(o)

        self.z2_error = self.o_delta.dot(self.W2.T)
        self.z2_delta = self.z2_error*self.sigmoidPrime(self.z2)

        self.W1 += x.T.dot(self.z2_delta)
        self.W2 += self.z2.T.dot(self.o_delta)

    def train(self,x,y):
        o = self.forward(x)
        self.backwards(x,y,o)

    def sigmoid(self,x):
        return 1/(1+np.exp(-x))

    def sigmoidPrime(self,x):
        return self.sigmoid(x)*self.sigmoid(1-x)```

When running this code to get a better understanding of neural networking, I ran into an issue that when feeding

```python
x = np.array(([0,0,0],
              [1,1,1],
              [1,1,0],
              [1,0,1],
              [1,0,0],
              [0,1,1],
              [0,1,0],
              [0,0,1],
              ),dtype=float)
y = np.array(([0],
              [1],
              [1],
              [1],
              [0],
              [1],
              [0],
              [1],), dtype = float)``` 

this information into the AI, it was preforming better when I left out the instance of [1,1,1] giving [1]. I was wondering if someone could explain why? When [1,1,1] [1] was left in, I was getting false positives for [0,1,0] and [1,0,0].

This goal was ment to predict a binary search tree of : A * B + C
jovial creek
#

feel free to ping me

somber bloom
#

Hi, is there ways to improve the registry searching using winreg?

analog flare
#

@unique jasper awesome project 👍 and nice blog

unique jasper
#

Thanks @analog flare !

brave mortar
#

Guys anyone ever worked on a self driving RC car project? Let me know. I need some help.

minor linden
#

Hey guys ✌🏼
Currently I am dealing with the topic online courses for coders.
I'm trying to find out how to make it easier for people to learn and would love to hear how you learn and stay up to date right now.
If someone has a few minutes for a quick chat it would be a great help for me.
Would be awesome if you just DM me 😊

acoustic fox
#

?

#

I've been learning 'online' <- not university for 3 years now

jovial creek
#

Just bumping this

class Neural_Network():
    def __init__ (self):
        self.inputSize = 3
        self.outputSize = 1
        self.hiddenSize = 2
        
        self.W1 = np.random.randn(self.inputSize,self.hiddenSize)/2
        self.W2 = np.random.randn(self.hiddenSize,self.outputSize)/2

    def forward(self,x):
        self.z = np.dot(x,self.W1)
        self.z2 = self.sigmoid (self.z)
        self.z3 = np.dot(self.z2, self.W2)
        o = self.sigmoid(self.z3)
        return o

    def backwards(self,x,y,o):
        self.o_error = y - o
        self.o_delta = self.o_error*self.sigmoidPrime(o)

        self.z2_error = self.o_delta.dot(self.W2.T)
        self.z2_delta = self.z2_error*self.sigmoidPrime(self.z2)

        self.W1 += x.T.dot(self.z2_delta)
        self.W2 += self.z2.T.dot(self.o_delta)

    def train(self,x,y):
        o = self.forward(x)
        self.backwards(x,y,o)

    def sigmoid(self,x):
        return 1/(1+np.exp(-x))

    def sigmoidPrime(self,x):
        return self.sigmoid(x)*self.sigmoid(1-x)```

When running this code to get a better understanding of neural networking, I ran into an issue that when feeding

```python
x = np.array(([0,0,0],
              [1,1,1],
              [1,1,0],
              [1,0,1],
              [1,0,0],
              [0,1,1],
              [0,1,0],
              [0,0,1],
              ),dtype=float)
y = np.array(([0],
              [1],
              [1],
              [1],
              [0],
              [1],
              [0],
              [1],), dtype = float)``` 

this information into the AI, it was preforming better when I left out the instance of [1,1,1] giving [1]. I was wondering if someone could explain why? When [1,1,1] [1] was left in, I was getting false positives for [0,1,0] and [1,0,0].

This goal was ment to predict a binary search tree of : A * B + C
long sleet
#

idk if this is the right place but... How can i transform an ogg file into m4a?

#

i mean... I want some tags ogg files dont have

#

{'language': ['eng'], 'encoder': ['Lavf58.18.104']}

#

those are the tags i can find on an ogg file so far

spiral swallow
#

i guess i would use ffmpeg

#

that's what i use to convert any audio/video

stark bridge
#

Ubuntu I think

#

that triangle logo in the upper left

fiery cosmos
#

Hi! I have a more theoretical based question. I have polygons and I'm trying to find gaps between points.
The polygons can be simple or complex. What would be the best approach to it?

Here some examples

#

What I did so far: I'm using shapely to get the convex hull of the polygon. Doing so I have the concavities, but I'm clueless what to do next

royal kestrel
#

it looks like you're trying to find the boundary of the shape within a specific region

acoustic fox
#

I don't know for sure

#

but I bet if you parameterize it in polar coordinates and take the derivative you'll be able to do this rather easily

jovial creek
#

Just bumping this

class Neural_Network():
    def __init__ (self):
        self.inputSize = 3
        self.outputSize = 1
        self.hiddenSize = 2
        
        self.W1 = np.random.randn(self.inputSize,self.hiddenSize)/2
        self.W2 = np.random.randn(self.hiddenSize,self.outputSize)/2

    def forward(self,x):
        self.z = np.dot(x,self.W1)
        self.z2 = self.sigmoid (self.z)
        self.z3 = np.dot(self.z2, self.W2)
        o = self.sigmoid(self.z3)
        return o

    def backwards(self,x,y,o):
        self.o_error = y - o
        self.o_delta = self.o_error*self.sigmoidPrime(o)

        self.z2_error = self.o_delta.dot(self.W2.T)
        self.z2_delta = self.z2_error*self.sigmoidPrime(self.z2)

        self.W1 += x.T.dot(self.z2_delta)
        self.W2 += self.z2.T.dot(self.o_delta)

    def train(self,x,y):
        o = self.forward(x)
        self.backwards(x,y,o)

    def sigmoid(self,x):
        return 1/(1+np.exp(-x))

    def sigmoidPrime(self,x):
        return self.sigmoid(x)*self.sigmoid(1-x)```

When running this code to get a better understanding of neural networking, I ran into an issue that when feeding

```python
x = np.array(([0,0,0],
              [1,1,1],
              [1,1,0],
              [1,0,1],
              [1,0,0],
              [0,1,1],
              [0,1,0],
              [0,0,1],
              ),dtype=float)
y = np.array(([0],
              [1],
              [1],
              [1],
              [0],
              [1],
              [0],
              [1],), dtype = float)``` 

this information into the AI, it was preforming better when I left out the instance of [1,1,1] giving [1]. I was wondering if someone could explain why? When [1,1,1] [1] was left in, I was getting false positives for [0,1,0] and [1,0,0].

This goal was ment to predict a binary search tree of : A * B + C
acoustic fox
#

@fiery cosmos So what you are doing is relaxing edges of a certain length, because technically

#

Are also gaps

#

You can apply a recursive smoothing algorithm that deals with weighted averages and a decay factor

#

If you are only looking for convex/concave you would track the curvature in either x, y coordinate..

#

You can find all inflection points that share positive slopes in both directions

#

Where you then say "This boundary is the largest closed surface once the tangent line to both slopes is = 180 degrees

jovial creek
#

Just bumping this

class Neural_Network():
    def __init__ (self):
        self.inputSize = 3
        self.outputSize = 1
        self.hiddenSize = 2
        
        self.W1 = np.random.randn(self.inputSize,self.hiddenSize)/2
        self.W2 = np.random.randn(self.hiddenSize,self.outputSize)/2

    def forward(self,x):
        self.z = np.dot(x,self.W1)
        self.z2 = self.sigmoid (self.z)
        self.z3 = np.dot(self.z2, self.W2)
        o = self.sigmoid(self.z3)
        return o

    def backwards(self,x,y,o):
        self.o_error = y - o
        self.o_delta = self.o_error*self.sigmoidPrime(o)

        self.z2_error = self.o_delta.dot(self.W2.T)
        self.z2_delta = self.z2_error*self.sigmoidPrime(self.z2)

        self.W1 += x.T.dot(self.z2_delta)
        self.W2 += self.z2.T.dot(self.o_delta)

    def train(self,x,y):
        o = self.forward(x)
        self.backwards(x,y,o)

    def sigmoid(self,x):
        return 1/(1+np.exp(-x))

    def sigmoidPrime(self,x):
        return self.sigmoid(x)*self.sigmoid(1-x)```

When running this code to get a better understanding of neural networking, I ran into an issue that when feeding

```python
x = np.array(([0,0,0],
              [1,1,1],
              [1,1,0],
              [1,0,1],
              [1,0,0],
              [0,1,1],
              [0,1,0],
              [0,0,1],
              ),dtype=float)
y = np.array(([0],
              [1],
              [1],
              [1],
              [0],
              [1],
              [0],
              [1],), dtype = float)``` 

this information into the AI, it was preforming better when I left out the instance of [1,1,1] giving [1]. I was wondering if someone could explain why? When [1,1,1] [1] was left in, I was getting false positives for [0,1,0] and [1,0,0].

This goal was ment to predict a binary search tree of : A * B + C
scenic mason
#

this is your 3rd time posting it here

frank nest
#

haha

scenic mason
sick arrow
#

Where can I learn the equivalent of a college level intro to discrete structures course online or via books?
I'm gonna take it in the summer and want to prepare in advance

last blaze
#

Mit open course ware probably has something

strong bough
#

may i ask at what point is it considered plagiarism when it comes to code?

topaz monolith
#

when you put your name on it

strong bough
#

if you take an algorithm on github and modify to complete your task

#

is that still ?

topaz monolith
#

if you say it's yours

#

and put your name on it

#

and don't include that you used anothers code

#

but you have to check with the original owner whether they allow reuse, reuse with modification, reuse with attrib. ....

last blaze
#

I don't know if theres a clear way to identify the point at which it becomes plagiarism if you're just opying relatively small snippets like that. For larger projects, they should have a licence dictating how you can reuse the code

strong bough
#

it's only 3 lines, but i guess i'll try to find another approach. thanks guys

last blaze
#

If its 3 lines, it's almost certainly OK

#

Just make sure you change its style to fit the rest of your code

jovial creek
#

Just bumping this

class Neural_Network():
    def __init__ (self):
        self.inputSize = 3
        self.outputSize = 1
        self.hiddenSize = 2
        
        self.W1 = np.random.randn(self.inputSize,self.hiddenSize)/2
        self.W2 = np.random.randn(self.hiddenSize,self.outputSize)/2

    def forward(self,x):
        self.z = np.dot(x,self.W1)
        self.z2 = self.sigmoid (self.z)
        self.z3 = np.dot(self.z2, self.W2)
        o = self.sigmoid(self.z3)
        return o

    def backwards(self,x,y,o):
        self.o_error = y - o
        self.o_delta = self.o_error*self.sigmoidPrime(o)

        self.z2_error = self.o_delta.dot(self.W2.T)
        self.z2_delta = self.z2_error*self.sigmoidPrime(self.z2)

        self.W1 += x.T.dot(self.z2_delta)
        self.W2 += self.z2.T.dot(self.o_delta)

    def train(self,x,y):
        o = self.forward(x)
        self.backwards(x,y,o)

    def sigmoid(self,x):
        return 1/(1+np.exp(-x))

    def sigmoidPrime(self,x):
        return self.sigmoid(x)*self.sigmoid(1-x)```

When running this code to get a better understanding of neural networking, I ran into an issue that when feeding

```python
x = np.array(([0,0,0],
              [1,1,1],
              [1,1,0],
              [1,0,1],
              [1,0,0],
              [0,1,1],
              [0,1,0],
              [0,0,1],
              ),dtype=float)
y = np.array(([0],
              [1],
              [1],
              [1],
              [0],
              [1],
              [0],
              [1],), dtype = float)``` 

this information into the AI, it was preforming better when I left out the instance of [1,1,1] giving [1]. I was wondering if someone could explain why? When [1,1,1] [1] was left in, I was getting false positives for [0,1,0] and [1,0,0].

This goal was ment to predict a binary search tree of : A * B + C
frank nest
#

@jovial creek If no one can answer, that’s it, why do you continue reposting over and over.

fiery cosmos
#

@acoustic fox thank you very much I'll have a look!

bronze gazelle
#

@frank nest if you have nothing constructive to contribute then try not responding at all

frank nest
#

@bronze gazelle Alright, sorry. I am just a bit getting mad at those types of people.

bronze gazelle
#

“These types of people” being people who want help?

#

In case you haven’t been paying attention, that’s what this server is for

frank nest
#

no, these types of people who continuously repost their question in different channels for several days

bronze gazelle
#

How else do you expect them to get an answer?

#

What is your proposed alternative?

#

Because telling them to go away isn't it

frank nest
#

I didn’t say them to go away, I just told that if no one is responding, reposting won’t work.

bronze gazelle
#

I’m sure lots of people are just scrolling through channel histories looking for questions to answer

#

If you’re frustrated, keep it to yourself

frank nest
pulsar vapor
#

hi am a new member of this python community is there anyone who is also trying to pass IGCES for computer science I'm asking this because I really need help with my mock exam assignment and was wandering if any else doing the same thing I am.

sudden sinew
#

What exam board are you on? @pulsar vapor

pulsar vapor
#

IGCSE year 11

#

its real easy but lmao i haven't done any python in 6 months and its all gone

lunar depot
#

so I have a problem and im not sure what hardware I would use to begin to seolve it. I need to track the motion of a helmet so that turning your head turns a camera that you are viewing through, problem is, I don't know if I should use an accelerometer or some sort fo two piece device that tracks helmet position realative to your shulders or something, or if I should go fro a different control method entirely.

jovial creek
#

working on some webscrapping tools but not understanding this HTML, can someone help me interoperate what its saying? feel free to ping

<p><b>Note: </b><i><script>var bb = document.getElementsByTagName("b");bb[bb.length-1].style.display="none"</script><input type="hidden" name="_status" value="277272282B2D2627" /><P><input type="submit" name="submitAnswers" value="Get a new version of this problem" onclick="document.getElementById('_reseed').value=25707" /><br/><style>.problemHeader {display:none}</style><input type="hidden" name="_reseed" id="_reseed" value="0" /></i></p>

#

cause I assume its calling a JS function to compare my answer with the new answer

#
<input id="previewAnswers_id" name="previewAnswers" onclick="this.form.target='_self'" type="submit" value="Preview My Answers" /><input id="submitAnswers_id" name="submitAnswers" onclick="this.form.target='_self'" type="submit" value="Submit Answers" />
#

the last one I believe is the submit answers the :

<input id="submitAnswers_id" name="submitAnswers" onclick="this.form.target='_self'" type="submit" value="Submit Answers" />```
#

ijust have no clue what its doing

haughty sleet
#

how do I calculate how many bits a long int variable is without using things like sizeof in C

warm marsh
#

real byte size of the Python object representing it in memory, or just how many bits would be needed in theory to represent a number?

haughty sleet
#

in memory

unborn hawk
#

So I know that the Reduce function applies an operation over all the elements of a list and returns just the final result. What's the official term for a function that returns a list showing the in-between results of each operation in addition to the final one?

#

would be easy to write but I'm sure there's a name for it already